• 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
Question by theUndeadEmo · Nov 01, 2013 at 02:25 PM · rigidbodyspeedforcedrag

Calculating the force required (Rigidbody)

Hi,

i was wondering how i could calculate how much force i would need to apply to a rigibody to get a certain speed (velocity.magnitude, lets say its 50 for this example) providing i have the following settings on my rigidbody

No Gravity Everything else is set to default with the exception of drag Drag = 5

so i have drag(5) and velocity.squaremagnitude (50), now i need to calc how much force i need to apply. to get my speed (velocity.squaremagnitude (50))

Comment
Mikael-H

People who like this

1 Show 0
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

3 Replies

· Add your reply
  • Sort: 
avatar image

Answer by khoramsql2008 · Nov 01, 2013 at 03:15 PM

force=1/2*mv*v which m is mass and v is velocity.

Comment
Mikael-H

People who like this

1 Show 0 · 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

Answer by brenosilver · Jan 06, 2015 at 11:45 PM

I've put a couple of answers together and came up with this:

 Vector3 forwardSpeed = (rigidbody.transform.forward * desiredSpeed);
 Vector3 force = (forwardSpeed.normalized * rigidbody.mass * desiredSpeed);
 force = (rigidbody.drag*force)/(1-0.02f*rigidbody.drag);
 
 rigidbody.AddForce(force);

This works perfectly for me as you can see here.
The console shows TopSpeed which calculates the terminal speed with a given force/drag/mass:

 float terminalVelocity = ((force.magnitude / rigidbody.drag) - Time.fixedDeltaTime * force.magnitude) / rigidbody.mass;


and Speed which is just the value of the slider or desiredSpeed. If both are equal that means the math works =)

Comment
SimonMV

People who like this

1 Show 0 · 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

Answer by Woj_Gabel_FertileSky · Mar 30, 2015 at 11:02 PM

This will not work when gravity is in play and collider is touching other collider, like a box on a flat plane. The equation needs to have this drag taken into account.

Comment

People who like this

0 Show 0 · 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

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

18 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

Related Questions

How exactly does Rigidbody Drag works? 3 Answers

Using rigidbody.AddForce and speeding the object 2 Answers

adding drag to a relative force 0 Answers

Touch controlled ice puck 0 Answers

Calculate force for torque by specifying a required velocity 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