Make input relative to rotation.

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

77026-3c802d913949a3e78407fbe23505182c.png

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.

thanks.

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;
inputDir.Normalize();

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