Make input relative to rotation.

So, i have a 2D animation blend tree like this:


Im using input.GetAxis for animations. The problem is that when i rotate like that, and press D, i need to play the backwards animation instead of the right walk animation.


It looks like you want the input to be relative to the camera:

Vector3 inputDir = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
inputDir = Camera.main.transform.TransformDirection(inputDir);
inputDir.y = 0;

However, if the camera looks straight down (90 degree angle), you have to swap the z and y axes.