Hi, I am trying to make a simple script where if you press the horizontal keys, a cube rotates ten degrees on the z axis, and if you press the vertical keys, it rotates ten degrees on the x axis. I have figured a script for it, and it works well but I have a problem. Normally, if I were to press a, the cube would smoothly rotate from 0 to 10 degrees, but if I were at 10 degrees already it would snap to 0 degrees and then move smoothly to -10. I can’t seem to find a solution the problem, here is my code:
void FixedUpdate () {
float horizontal = Input.GetAxis("Horizontal");
float vertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(vertical * maxangle, 0.0f, -(horizontal * maxangle));
rb.transform.rotation = Quaternion.Euler(movement);
}
By the way, maxangle = 10.
I am a beginner so I cannot find an answer. Any help would be appreciated! Thank you!