Hello all, first time posting here ![]()
I have been trying to find a solution to this issue for a while. I do understand what the root cause is, but I am failing to find a robust solution.
I have a character that is using root motion (not necessarily relevant to the issue as far as I know?). The movement works fine for most cases. For calculating the direction of movement, I am using the following which gives me the direction that player wants to move towards, based on their input:
const FVector InputDirection = CharacterRef->GetActorForwardVector() * InputForwardValue + CharacterRef->GetActorRightVector() * InputRightValue;
InputForwardValue and InputRightValue may be 1.0, 0, or -1.0.
Then, I am calculating the angle of movement (between -180.0 and 180.0) to pass into my blendspace, using the following line in my AnimInstance class:
float Angle = CalculateDirection(ActiveMovementDirection, CharacterRef->GetActorRotation());
The problem: When I am having the character move back (InputForwardValue is -1.0), Angle gets calculated as 180.0. Makes sense. When I also press A to set InputRightValue to -1.0 as well, the calculated angle will become -135.0. Makes sense. The issue is, the interpolation will happen from 180.0 to -135.0 which means, my character starts rotating counter-clockwise 315 degrees.
I know that to fix this, I need to have it consider 180.0 βlikeβ -180.0, so that it can interpolate it from -180.0 to -135.0 in this case. Is there any support in the engine to handle this? What am I missing? It seems like this should be a simple thing to do.