Movement direction relative to character rotation

OniricMaster
Wed, 13 May 2020 23:57:10 +0000
Character & Animation

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.

4 posts - 1 participant