- Home /
This question was
closed Jun 20, 2014 at 10:13 PM by
meat5000 for the following reason:
The question is answered, right answer was accepted
Question by
Sares · Jun 20, 2014 at 03:23 PM ·
c#rotationquaternionjoystick
Joystick movement conversion to angle doesn't work anymore in C#
It worked perfectly in JavaScript:
var newRot = Quaternion.LookRotation(Vector3(Input.GetAxis(xAxis), 0, Input.GetAxis(yAxis)));
controller.transform.rotation = Quaternion.Lerp(controller.transform.rotation, newRot, Time.deltaTime*10);
Now in C# it doesn't work anymore:
Quaternion newRot = Quaternion.LookRotation(Vector3(Input.GetAxis(xAxis), 0, Input.GetAxis(yAxis)));
transform.rotation = Quaternion.Lerp(transform.rotation, newRot, Time.deltaTime*10);
LookRotation only wants a forward (optional an upward) parameter, strangely it worked in JavaScript. It controls the player character from a top down view with a locked camera angle.
Comment
No, the error happens in the first line. It has no errors if I write Vector3.forward for example. I just don't know why it works in JavaScript.
Best Answer
Answer by Sares · Jun 20, 2014 at 08:33 PM
Yes they do. I wrote Vector3 instead of new Vector3... it's always the little things. Thank you anyway. That's the new working code:
Vector3 input = new Vector3(Input.GetAxis("Horizontal"),0,Input.GetAxis("Vertical"));
targetRotation = Quaternion.LookRotation(input);