• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Gindy · Dec 13, 2018 at 01:58 AM · physicsforcetorqueaddtorqueforcemode

AddTorque does not use ForceMode as expected (Different than AddForce)

Currently using Unity version 2018.2.5f1

If a rigidbody has a mass of 1, ForceMode.Force and ForceMode.Acceleration should be the same, right? This appears to be so with AddForce, but not with AddTorque. ForceMode.Acceleration results in less torque than ForceMode.Force. Is this intended behaviour? I'm not familiar with the math.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by roddles · Aug 21, 2020 at 02:12 AM

While force, F = m × a, torque, T = I × α, where I is the rotational (the moment of) inertia, and α is angular acceleration. For a very simple point mass, I = m × r², but for objects that have mass and volume, (without getting deep into the physics), there is instead an inertial matrix (formally the inertial tensor), in which each component of the matrix represents the resulting inertia on a combination of two axes: the axis of rotation and one of the three cardinal directions. Thus a group of three components for a given axis of rotation indicate the inertia in the x, y, and z directions.

So, on to Unity's torque implementation, the rigidbody component includes an inertialTensor member variable. If the inertialTensor is not manually set by script, Unity will automatically calculate it using information from the collider and store it in inerntialTensor, which will be used when calling ApplyTorque -- with a forcemode that includes mass -- to find the angular velocity vector.
To bring all this together: whereas AddForce and ForceModes take into account just mass, AddTorque and ForceMode must take into account Inertia, which as you can see from above, is an entirely different beast that depends not just on mass, but also the shape and dimensions of the object's collider.
HTH.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Gindy · Aug 21, 2020 at 09:20 PM 1
Share

Wow, I wasn't expecting an answer after so long. Thanks! I can barely remember what I was trying to do. That helps me understand what's going on a bit better, but I was comparing not just with a mass of 1 but also the same collider with the same shape and dimensions. So wouldn't the inertialTensor be calculated the same? I'm pretty sure it was under these conditions that Force$$anonymous$$ode.Acceleration resulted in less torque than Force$$anonymous$$ode.Force. Exact same object, just changed the Force$$anonymous$$ode. I was using 2018.2.5f1 so if it was a bug maybe it's been fixed by now.

avatar image roddles Gindy · Aug 21, 2020 at 10:03 PM 1
Share

Yeah, I answered just in case someone else came along and had the same problem.

So, the difference is that when you call AddTorque() with different force modes, the way the angular acceleration is calculated will be different. With Force$$anonymous$$ode.Force, you indicate that the "force" parameter to AddTorque is a torque, so it needs to calculate angular acceleration using the formula, α = T / I, whereas with Force$$anonymous$$ode.Acceleration, you indicate the parameter is the angular acceleration, α, so there is no adjustment made to the value passed in.

avatar image Gindy roddles · Aug 22, 2020 at 02:50 AM 0
Share

Oh I get it now. Thanks.

avatar image roddles · Aug 21, 2020 at 10:15 PM 1
Share

In the end, I found that torque and angular acceleration for my project was overly complicated. Instead I just started applying the angular VELOCITY that I wanted directly, without accelerating from 0 to my desired angular velocity and then decelerating back to 0 just in time to hit the correct heading with zero angular velocity. It's just not really necessary unless you have extremely massive objects and need those very realistic physics.

I do this by:

  1. Calculating the delta in angular velocity I need using an equation like targetAngularV - currentAngularV, the former you will need to calculate, the latter is available from the rigidbody.

  2. Clamping this value to a maximum angular velocity e.g. $$anonymous$$athf.Clamp(deltaAngularV, rigidbody.maxAngularVelocity)

  3. Passing this delta of angular velocity to rigidbody.AddTorque(deltaAngularV, Force$$anonymous$$ode.VelocityChange)


I find this far easier to manage, and is very similar to the way most games feel.

avatar image Gindy roddles · Aug 22, 2020 at 02:59 AM 0
Share

I like that.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

166 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Figuring out the correct amount of torque to apply? 2 Answers

Physics object slides while turning. 1 Answer

AddTorque() doesn't work when also using AddForce() 1 Answer

AddTorque application is too slow 1 Answer

AddRelativeTorque not rotating 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges