Character Movement Direction.

Hello am setting up some new animation Blueprints.
And having some trouble getting the direction of my character.

Now speed was not a problem.


But can someone give me some advice on direction?

How can i determine if my character is moving left or right.
Backwards or forward, or at a angel?

To illustrate i made this.

Thanks for any advice.

Forward/backwards/left/right are all relative, so generally what you do is check the input values themselves. If I get the input values for my “MoveForward” axis, then I know > 0.0 is moving forward, < 0.0 is moving backwards. Same with “MoveRight” to determine left/right movement.

Here’s some helpful links on this:

Hey thanks alot mate!
It never struck my mind to get the axis value.

For anyone intrested here is the method, I use in my Anim Graph.

FVector UMyAnimationInstance::GetPlayerMovementInput()
	AMyPlayerClass* MyPlayer = Cast<AMyPlayerClass>(GetOwningActor());
	if ((MyPlayer) && MyPlayer->InputComponent)
		return FVector(
				, MyPlayer->InputComponent->GetAxisValue(TEXT("MoveRightLeft"))
				, 0);
		return FVector(ForceInit);


For most cases using a standard character, there will not be a big difference between axis values and movement speed. Axis values are translated more to acceleration, but generally for characters there is not much drifting going on so using input values will probably work fine.

But if you really want to know instantaneous movement direction, you can use the dot product as follows. This will deal correctly with cases where, for example, your input is reverse, but your characters momentum is still carrying him forwards.

FVector Vel = Character->GetVelocity();
FVector Forward = Character->GetActorForwardVector();
FVector Right = Character->GetActorRightVector();
float ForwardSpeed = FVector::Dot(Vel, Forward);
float RightSpeed = FVector::Dot(Vel, Right);

To clarify, these values give you the components of velocity in the direction the character is facing, and perpendicular to the direction the character is facing. Negative values mean the character is moving backwards/to his left.

This is a good point, in all honestly you’ll probably want both methods: Input Direction, and Velocity Direction so you can better tailor your blend spaces to match what is happening to the characters vs player intent.

Ahe yes this was defenetly a better solution.
Thank you so much for your help guys!


How to make move any playable ue4 character just like main playable character in Sonic X-Treme(that cancelled Sega Saturn game from the late 90’s)?