I am trying to get 4-way directional evade related to an enemy. I have a rotation lock-on system on the character that always updates his rotation towards the lock-on target.
Now I tried many ways to get character to roll to one of 4 ways (forward, right, left, back) depending on the player’s input.
One of the ways I tried is by saving player’s input by setting 2d vector (something I found on youtube) and then tried doing all kinds of weird maths to get it to work. I was trying to get input direction from -1 to 1 and then using booleans or some other logic to set a direction for the roll when button is pressed.
This gives my a range of -180 to 180 degrees, where the negative values indicated movement “to the left” of our current lock on target, 0 means towards the target and positive values “to the right” of the target.
Finnaly i just use branches to determine which montage to play depending on the angle.