How to convert the resultant vector to a rotator?

Hello! I’m just getting started in UE4 for the first time, and would like some help on a basic blueprint I’m making. I’m trying to create a third person movement where rather than the character turning to face their running direction, they always face forward and use a 2d animation blendspace to pick the right strafing / forward / backwards animation, using speed and direction. Everything is going well except I am having some trouble finding their direction relative to their forward vector. I figure what I should do is take the pawns forward vector, subtract the normalized velocity vector, get the rotation from that, and then finally break it and use the yaw. I’m not sure how to convert the resultant vector to a rotator though, any help would be lovely!

Thank you :slight_smile:

If you need a float describing the movement component relative to the forward vector your could simply use the angle between the forward vector and the velocity vector. That would simply be the ACOS of the dot product of both normalized vectors. But maybe I misunderstood you and you are trying something different.

Thanks for taking the time to reply :slight_smile: The dot product would be finding the angle in between my forward and velocity vector, what I want to do is essentially take the velocity angle and take its direction from global to local. That way when I press A on the keyboard, it should give a value of -90, 0 at W, 90 at D, and 180 or -180 at S.

One question:

Does your character go where the camera is pointing to when you press ‘W’ (forward)? In that case, you could take the Camera forward vector for the calculation. You will have to convert it to a Rotator using ‘From XVector’

Another option:
Use the controller rotation.

In both situations, you can create a Rotator using ‘From Xvector’ node and you Pawns velocity vector, and use ‘Rot Delta’ to find the difference between Rotators.

Yes, the character is always looking in the direction of the camera, so if I hit S he would be strafing left, with his back still to the camera. I think this is just the ticket, I didn’t think about using the camera or controller rot, thank you very much :slight_smile:

Convert velocity to local vector of Actor then find the angle between local velocity and the local forward vector of Actor.
You can try this.