Greetings, i’m currently developing a twin stick shooter and i’ve reached a bit of a road block. Basically i’m 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.
Thanks for the idea although I’ve already used blend spaces before and I don’t see how i can determine the rotation relative to the aim direction using that. When the player is aiming at lets say direction 0. If he wants to move backwards it would have to be 135 to 180 or -180 to -135. If direction is -90. If he wants to move backwards it would have to be 45 to 90 or 90 to 135. Since the variables keep changing using a blend space I feel would not be able to work unless I added some sort of equation so determine the correct direction. Which is basically what im doing now but without a blend space. I might be completely wrong though.
Here I explain the setup for the controller and character to have separate direction of movement and separate direction of looking. and how they are calculated.