Rotation Reset Help

I need help resetting the rotation of the x-axis back to 0, while the rotation on the y-axis keeps going. It’s basically code for a turret enemy in my game. Here’s the piece:

  void RotateMode()
    {
        transform.Rotate(new Vector3(0f, 100f, 0f) * Time.deltaTime);
    }

Any help is appreciated.

You want to have separate float values for traverse and elevate and adjust those values only.

Check this post here, I did a whole writeup about it, including some sample code:

1 Like

Have you tried eulerAngles? Like this:

transform.eulerAngles = new Vector3(0f, transform.eulerAngles.y, transform.eulerAngles.z);
1 Like

Yep. I just found out. Works like a charm.