Question by
Tageos · Feb 14, 2016 at 05:54 PM ·
c#rotationquaterniontime.deltatime
-= Time.deltaTime
Hello!
When holding down A my object rotates to the left, when i hold in D my object should rotate right but it does not:
if (Input.GetKey(KeyCode.A)){
Debug.Log("left");
Quaternion Temp = transform.rotation;
Temp.z += Time.deltaTime;
transform.rotation = Temp;
}
if (Input.GetKey(KeyCode.D)){
Debug.Log("Right");
Quaternion Temp = transform.rotation;
Temp.z -= Time.deltaTime;
transform.rotation = Temp;
}
When holding down D in game mode the object immideatly rotates 360 degrees and "shakes" when i continue holding down D. I want the object to gradualy get a negative rotation around the Z-axis when holding down D, just as i get when i hold down A (but the opposite).
What would i do to fix this?
Thank you!
Comment
Best Answer
Answer by hexagonius · Feb 14, 2016 at 06:22 PM
Do not alter Quaternions just like that. Instead use something like Quaternion.Euler, which will work with angle values.
Okay yeah, i just noticed that moving left also had a few bugs. Ill check it out thank you!