Orient Rotation only on forward

Hello,

what would be the best way to make the character rotatate to movement only on the forward movement (so I can implement strafe animtions and backward run, without rotating the character there)?

I only found “CharacterMovement->bOrientRotationToMovement = xx”. which either disables it completely or makes it rotate in all directions.

I am gratefull for c++ or blueprint solutions, but I rather prefer doing it in editor/blueprint.

Thanks in advance!

I guess i don’t understand what you want to achieve.

You want to stop the rotation of your character? Or what is “rotate to movement only on the forward movement”? :smiley: Does this mean you want that the character can only rotate if he is moving forward?

Yeah basically.

I want to rotate the camera around the character freely, as it is in the third person template. So when I watch at my character from the front view, I want him to turn around as soon as I press W. But If I press A or D I want him not to rotate, so I can strafe

Ok, you would need to disable the A and D buttons, or at least use some branches and bools to toggle rotation. In your project settings, you will find inputs that are probably set to A and D for rotation or something like that.

In your CharacterClass or inside the Controller Class (depens on your setup), there should be a part where the rotation is controlled by the Input that belongs to A and D. This is the part where you need to disable it. Either delete it, or use branches etc.

For the W part. You will need to get the direction of the camera. You can get the forward vector of the camera for example, or use the rotation and calculate the forward vector from the yaw value. There are a few more ways to do this.

If you have the direction, you need to add input for the W key. I guess there is already an input for it if you are using a template (first/third person). So there is also a part in the character/controller class for the W key. Check this part and change it to let the character move in your new direction.

I seem to have managed to solve it, but I thank you for you efforts nonetheless. I read that too late I guess :smiley:

Please provide a small answer with your solution and mark it as solved (:

One way I found of doing this was to create a key event for whichever movement keys you want the character to stop rotating for (eg. A,S & D), then drag out from ‘Pressed’ and create a ‘Set Use Controller Rotation Yaw’ node, then tick the checkbox, then do the same for ‘Released’ except this time leave the tick box unchecked. It should look something like this (I only set mine for the ‘S’ button, but just link any additional key nodes to the ‘set’ nodes if you want to lock rotation when that button is pressed):