Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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
1
Question by _Prism_ · Nov 06, 2019 at 01:25 PM · rigidbody2dtorquemass

Mass not effecting torque

Hi all,

I'm making a 2D space game where the heavier the ship gets, the harder it is to move/steer. While the linear movement is effected as the rigidbody's mass increases, the angular acceleration is not. Here's my code:

 rb.AddTorque((Input.GetAxis("Turn") * tmpEnginePower * rateOfTurn), ForceMode2D.Force);

With or without the ForceMode2D argument the same thing happens. The same rate of torque rotates the rigidbody at the same rate no matter what its mass is. Different torque values do change the angular acceleration but the mass doesn't. Changing the torque value based on the vehicle's mass seems like a really backwards way to achieve the behaviour I want. Angular drag works as expected but that's not what I'm after as the game is in space, hence no drag. What am I missing?

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
4
Best Answer

Answer by _Prism_ · Nov 14, 2019 at 03:02 AM

Ooookay, so as I suspected, I was missing something. In my defense it's easy to miss. I know in real world physics, the phenomenon I'm describing is inertia, but there's no inertia setting in the inspector component of a Rigidbody2D. Except there is - it's buried in the Info box of the component (which closes every time you enter play mode, so that doesn't help) and unlike the angular drag variable it can not be modified in the inspector - it's greyed out. The inertia variable is however accessible via script, so now I set the inertia float whenever the ship's mass changes. Heavier the ship gets, the harder it is to turn. Exactly what I want.

Comment
Add comment · Show 6 · 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 Ermiq · Nov 14, 2019 at 12:54 PM 2
Share

Nice to see people posting their solutions ins$$anonymous$$d of just closing the question with 'Solved on my own'.

avatar image _Prism_ Ermiq · Nov 15, 2019 at 04:07 AM 0
Share

I figured it might be useful for someone else if they miss the same thing I did =)

avatar image Pangamini · Nov 14, 2019 at 02:03 PM 0
Share

Normally the inertia tensor is calculated from the shapes and mass of attached colliders, and possibly automatically recalculated when they move. Setting the intertia tensor by script will disable this automatic feature, probably that's why it's greyed out. To re-enable automatic inertia tensor calculation, call Rigidbody.ResetInertiaTensor();

avatar image _Prism_ Pangamini · Nov 15, 2019 at 04:09 AM 0
Share

Thanks man, that's good to know. As I'm updating the inertia manually at the same time I update the rigidbody's mass, the effect of inertia should be correct shouldn't it?

avatar image Bunny83 Pangamini · Nov 15, 2019 at 04:21 AM 0
Share

Note that the story is slightly different for Physics2D which uses a completely different physics engine. You do not have a tensor but just a single inertia value since we only have one rotation plane in 2d. I have never used Unity's 2d physics (which uses the Box2D engine). However Collider2D seems to have a density property and when actually using it you don't want to set the mass manually. I'm not sure if the inertia is actually calculated automatically when "useAuto$$anonymous$$ass" is true. That's something someone has to test since the documentation isn't explicit here.

avatar image _Prism_ Bunny83 · Nov 15, 2019 at 05:15 AM 0
Share

Interesting. I'm going to do some testing to get the 'feel' of what mass values to use with what engine power/torque values, so I'll have a look at that too =)

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

119 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

Related Questions

2D Torque rotation - stop at certain angle 0 Answers

rigidbody2D.AddTorque() works differently on iOS, in editor and in web player 1 Answer

Angular velocity not affecting Rigidbody2D 1 Answer

How to make a rigid body move along a specific path using my mouse? 1 Answer

Problem with Rigidbody2D.angularVelocity 0 Answers


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