I've broken this up into three sections: log results, the function in question, and what was added to the function to fix the issue.
log:
Code: Select all
ScriptLog: R1: 0,16384,0
ScriptLog: R2: 1044,12287,0
ScriptLog: R3: 64492,4097,0
ScriptLog: R3 Adjust: 64492,4097,0
ScriptLog: RotResult: 0.000000
ScriptLog: NewSpriteIndex: 0Code: Select all
final function int AdjustDirIndex(Actor sAnimated, RPG_Camera Camera, out int NewSpriteIndex)
{
local Rotator R1,R2,R3;
local int IndexMax, OldIndex;
local float RotResult;
local bool bCounterclockwise;
IndexMax = 8;
R1 = sAnimated.Rotation;
log("R1: " @ R1);
R2 = ( Rotator(Camera.Location - sAnimated.Location) + rot(0,-4096,0) );
log("R2: " @ R2);
R3 = (R1 - R2);
log("R3: " @ R3);
[INSERT BELOW CODE HERE]
RotResult = ( ( R3.Yaw / (65536 / IndexMax) ) ) - ( ( ( R3.Yaw / (65536 / IndexMax) ) ) % 1 );
log("RotResult: " @ RotResult);
NewSpriteIndex = int(RotResult);
OldIndex = NewSpriteIndex;
if ( OldIndex > IndexMax )
{
NewSpriteIndex = ( OldIndex % IndexMax );
log("IndexAdjust: " @ NewSpriteIndex);
OldIndex = NewSpriteIndex;
}
else
log("NewSpriteIndex: " @ NewSpriteIndex);
return NewSpriteIndex;
}Code: Select all
if (R3.yaw < 0)
{
bCounterclockwise = true;
R3.yaw =- R3.yaw;
}
if ( R3.yaw > 65536 )
R3.yaw = R3.yaw % 65536; // throw away all multiple rotations of 360°
if (bCounterclockwise && R3.yaw != 0)
R3.yaw = 65536 - R3.yaw; // make counterclockwise to clockwise
log("R3 Adjust: " @ R3);