Blending correctly while strafing and rotating mouse

Hey community,

I have an issue when setting up strafing. Essentially, when strafing and rotating the actor with the mouse I should be getting a forward run or backward run but instead it blends weirdly between strafing and forward/backward since the animation blueprint has no way of interpreting direction in space correctly when rotating and strafing. Does this make sense? I essentially need a way to determine the direction in space (or the direction of the actor) and set a transition rule accordingly so that it blend from strafing to running forward or backward. For example, if I strafe to the right and rotate with the mouse to the left, the actor should run backward in a circle in space to the right, or if I do the same but rotate with the mouse to the right, the actor should run forwards in a circle in space to the right. Basically strafing and then rotating with the mouse should be interpreted correctly in the blend space as a running forwards or backwards in a circle.

You can determ locomotion direction by controller velocity vector in world space, first project velocity vector on plane with normal = controller up vector, and normalize resuilt.

Can you show us a video?

Yes! I will make one today. Thank you for investing in the question. A video will show the issue very clearly… essentially strafing is a sideward movement, and if I rotate while strafing it leads to weird blending and foot sliding. Hopefully the video will clarify, will make it asap for you!

I think I have faced that problem before, that is also present if you download the Anim Starter Pack, right?

if that it I have a solution for it, basically involves dot products and 2 new animations which I created in-Engine using Add Bone Transform to additive layer. This still isn’t perfect but it will mask the issue about 90% of time, unless the player rotates very quickly still it isn’t that bad.

Ok so the Blendspace looks like this and we need to feed it 2 values which we get via this function running every tick.

// Get Character Velocity
	FVector CharacterVelocity = GetCharacterMovement()->Velocity;

// This will tell you with how much speed character is moving forward or right
	ForwardSpeed= FVector::DotProduct(CharacterVelocity, GetActorForwardVector()) / MaxSpeed;
	StrafingSpeed= FVector::DotProduct(CharacterVelocity, GetActorRightVector()) / MaxSpeed;

Now all you need to do is put the Forward Speed (Speed Param In my Blendspace) and Strafing Speed (Direction Param in Blendspace).

Hope this helps.

IMPORTANT: You need 2 more animations for this sadly the Anim Starter pack does not have those by default its an 8 Direction Blendspace needs 8 Poses/Animations to work Anim Starter pack comes with 6. I can send you those but you will need to retarget them I suppose.


So this will kinda mask the issue but not entirely,sadly the proper fix is getting new animations.

This is an excellent solution! Thanks for sharing.
However, my blendspaces and therefore state machine logic looks very different. I’ve got each direction in it’s own blendspace and instead use separate states in a state machine for each direction. The animations go through a linked anim layer that are then called upon in each directional state in the state machine. The problem is the same as the one you outline though. Not sure if this makes any sense? Perhaps the same solution could work, what do you think?
Video of my issue: strafing issue - YouTube

I think then the only way to fix it would be doing this the old school way instead of calculating the speed, use the input value and feed it directly, This however for me would be an overkill in multiplayer because I just use the Velocity and all the clients determine the animation state own their own.

What method are you using? for getting the values forward and direction?

Basically I normalize the velocity, unrotate that vector with actor rotation and then I get a direction vector that I divide by the absolute total float sum of that vector with itself and set a new vector. Then I clamp that between -1 and +1 on the x of the vector, same for the y but multiplied by -1… This goes into a struct for forward/backward and left/right…

It’s a bit complicated but that’s basically it… Then I cache each direction through a linked anim layer and call all of them in my “direction state machine” through a multiblend that uses the direction calculation for the alphas…