Beginner here. Been trying for a while to find a way to get the direction of my character’s movement. I need to know if the character is moving forward or backward so I can apply different animations to each direction.
I’m making the character move forward like this:
MovementComponent->AddInputVector(GetActorForwardVector() * AxisValue);
There’s nothing custom at this point about my Character or its default PawnMovementComponent, it’s just the out of the box UE4 Character.
I’ve tried quite a few ways to do this seemingly simple thing, including reading the MovementComponent’s Velocity and its GetLastInputVector(). The InputVector’s size tells me if the character is moving or not, but not the direction. I think that Velocity is the correct vector to read this information from, but I’ve been logging various variables from the Velocity vector and they all look like nonsense values. Two examples are the Velocity.X and Velocity.Rotation().Yaw, the values look like this when written from Character Tick function while moving forward or backward, logs 0 when standing still:
-1073741824
-1610612736
-2147483648
-536870912
1073741824
-536870912
-1610612736
536870912
They’re very large and flip between positive and negative.
Any help would be much appreciated, I’m surprised by how hard it’s been to read this seemingly straight forward value, but maybe I’m misunderstanding something.