- Home /
How to get the correct Input direction based on the camera angle to use in a rootmotion based third person controller
I move my character based on the rootmotion of their animation using a blend tree that uses 2D Freeform Cartesian input (Vertical, Horizontal)
if Vertical = 1, the character moves forward based on the direction he is facing
if Horizontal = 1, the character turns right based on the direction he is facing
and the rest of the system follows, here is the current Blend Tree:
Currently, if i press forward, the character move forward no matter where the camera is facing:
But in this example, what i want is for the character to slightly make a turn left to face the camera direction and then start walking forward:
When working on a game that moves the character by code (without rootmotion), something like this would solve the issue:
_inputAxis = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0);
_inputCam = Quaternion.Euler(0, _cam.transform.eulerAngles.y, 0) * _inputAxis;
And then use _inputCam to move the character, but for some reason this isn't working, and these two variables are always equal to each other, what am i doing wrong ? also if there is a "standard" solution for this problem (am sure it is) please link it (doesn't matter if its Unity or not as long as the code is readable)
Thanks!