Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

No way to freeze local z-rotation?

Discussion in 'Physics' started by h0nka, Sep 27, 2017.

  1. h0nka

    h0nka

    Joined:
    Apr 7, 2013
    Posts:
    109
    Hi,

    I have tried a bunch of different things now and I can't seem to lock the rotation on the local z-axis of my rigidbody. Using either rb.angularVelocity or rb.addTorque to set x, y-rotation with GetAxis input (horizontal for x, vertical for y) how do i constrain the rotation of the object so it does not rotate around z?

    Thanks!
     
    Last edited: Sep 27, 2017
  2. h0nka

    h0nka

    Joined:
    Apr 7, 2013
    Posts:
    109
    Doesn't work with editor constraints or FreezeRotationZ...
     
  3. Plystire

    Plystire

    Joined:
    Oct 30, 2016
    Posts:
    142
    If I rotate X by 90 degrees and then Y by 90 degrees, I've effectively rotated the object around Z by 90 degrees without directly changing it.
    Similarly, if I rotate Z by 90 degrees and then X by 90 degrees, I've effectively rotate the object around Y by 90 degrees.

    That's probably the issue here. What is your desired outcome in this scenario?

    If, even in these scenarios, the "effective rotation around the Z axis" should be constrained then you will want to actively detect and counteract it.