Search Unity

Rigidbody AddTorque unexpected behavior on one axis

Discussion in 'Physics' started by _Amael_, Nov 8, 2016.

  1. _Amael_

    _Amael_

    Joined:
    Aug 20, 2012
    Posts:
    19
    I'm trying to rotate a simple rectangular rigidbody using torques, but I'm getting weird results when the rigidbody is at certain angles.

    For example, when the rigidbody's initial rotation is 0, 0, 0, a torque around the world Y-Axis behaves as expected (the rigidbody rotates its centre about the y-axis). The same is true if the rigidbody's initial rotation is 0, 0, -30. However, if the initial rotation is -30, 0 ,0 then the rigidbody's rotation goes haywire and the rigidbody is spun about in all directions.

    pic.jpg

    I've attached a simple project/scene to demonstrate the problem - press play and then the "up" arrow key to make the rigidbodies rotate. The one on the left rotates using AddTorque on the world's Y-Axis, the one on the right uses Rigidbody.MoveRotation on the world's Y-Axis.

    You can set the initial rotation for the rigidbodies to the values described above to see that the weird behaviour is only happening when there's an initial rotation on the X-Axis.

    The behaviour on the right rigidbody in the scene is what I need to happen (by using torques, not MoveRotation).

    I've been stuck on this for two days now and I'd really appreciate any help or insight that people could offer - it seems to be such a simple problem but I can't find a solution to it.

    Many thanks
     

    Attached Files: