Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Torque and inertia in Rigidbody2D scripting manual

Discussion in 'Documentation' started by Sinnii, Jan 22, 2016.

  1. Sinnii

    Sinnii

    Joined:
    Oct 14, 2013
    Posts:
    2
    I've been working some with this aspect of Unity lately and have found the documentation to be lacking.

    First there is the inertia member variable. This is effectively the mass when talking about rotation. The mass member has a detailed explanation about how it relates to force and acceleration, but the inertia member does not. Simply explaining that rotationalAcceleration = torque/inertia would be helpful for newcomers.

    Secondly, when you request the rotational speed from the rigidbody using angularVelocity, you get back a value in degrees/second. This is fine and documented. The problem is the AddTorque function. If you go by angularVelocity, you would expect this to be degrees/sec^2 = torque/inertia. However, it's actually radians/sec^2 = torque/inertia. The result of which is that any torque you apply must first be multiplied with the Deg2Rad constant for it to be predictable, if your own calculations were done using degrees(which is likely since angularVelocity gives deg/sec). And this is *not* mentioned in the documentation for AddTorque.
     
    Deeeds likes this.
  2. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    Why has nothing been done about this?

    He's right, and this was more than 2 years ago.

    This post comes up as the 5th response to googling "Rigidbody2D.inertia"
     
  3. ownezx

    ownezx

    Joined:
    Mar 29, 2018
    Posts:
    6
    He's right, and this was more than 3 years ago.

    This post comes up as the 2th response to googling "Rigidbody2D.inertia", I wish I had seen that in the scripting documentation before scratching my head for a while.
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    2,025
    Because it hasn't been reported. A bold highlighted question on a forum post won't get changes made as forum posts often get overlooked. You can report issues like this using the standard bug reporting mechanism. These won't get forgotten about and are a great way for you to track fixes/changes too.

    Luckily a docs dev stumbled across this post and made me aware of it so I just made some changes to the descriptions for both Rigidbody2D.inertia and Rigidbody2D.AddTorque that include example code showing how to affect a change in angular velocity in degrees using a torque impulse.

    Bit late but sorry for the confusion.
     
    Last edited: Aug 28, 2019