I am trying to rotate the input axis by an angle offset, depending on where the character is looking.
Vector3 input = new Vector3(Input.GetAxis(“Horizontal”), 0f, Input.GetAxis(“Vertical”));
Quaternion targetRotation = Quaternion.LookRotation (input, Vector3.up);
transform.Find (“Aim”).rotation = targetRotation;
float angle = Vector3.Angle(transform.forward, transform.Find(“Aim”).forward);
Vector3 cross =Vector3.Cross(transform.forward, transform.Find(“Aim”).forward);
if(cross.y >0)
angle =-angle;
input =Quaternion.AngleAxis(angle,Vector3.up)*Vector3.forward;
The Aim game object is set by the input axis. The character should still move given an X, Y axis whilst still looking at a target, using a RTS-style camera. As I am using the animator to move the character, I need to figure out how to set the blend tree coordinates to move relative to where the character is facing.
I am getting weird blending results due to the axis not being constrained to a square. A 45 degree turn results in (0.7, 0.7) instead of (1, 1). Is there a way I can stretch the Vector to snap to a 1,1 square, or a generally better way to achieve what I am working towards?
UPDATE: To try my project so far https://00f075b097c7f17b07b129853fa6163224ef9d62.googledrive.com/host/0B6rDPzFC8Iitb1Q3THdtZlZpb28/Unity.html