Download

Setting the movement direction relative to the player rotation.

Greetings, i’m currently developing a twin stick shooter and ive reached a bit of a road block. Basically im just trying to determine what direction the player is moving relative to the direction he is looking at. I’m doing this so I can then set walking animations based on which direction the player is moving in.

I’ve managed to set up a basic system that kinda works but not always.

1 - I’ve created a function called Movement Direction which receives a vector input. (Left JoyStick Axis) this function is called every time the player uses the left joystick.


2 - Inside that function I try to determine which direction the player is facing based on a range of floats. (The following blueprint shows how I determine that the player is moving forward or not.)
The issue here is that for example if the movement direction is 175 and then I add 45 it goes to 220 which isnt a valid number for the yaw since it goes from -180 to 180.
I understand where the problem is I just cant figure out the correct solution.
Any ideas would be greatly appreciated. Thank you.