Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
2
Question by spaceshooter · Feb 23, 2011 at 12:38 AM · physics

How is drag applied to force?

How does a rigidbody's drag value work with force? Let's say a force of 5 is added to an object which has a drag of 1. ForceMode.Force in FixedUpdate().

I'm interested in the formula used to determine the velocity. Thanks!

A guess: velocity.y - ( drag * (fixed time step/10) ) That seems to match up... but is it right? The division is because it seems to be one decimal place off compared to what I see in practice, so I think I'm missing a piece.

Comment
Add comment · Show 1
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 dissidently · Mar 07, 2011 at 04:10 PM 0
Share

there are a bunch of questions about this expressed in different ways. And I've never seen an answer. The answer would be a wonderful thing.. cause then we could calculate the amount of force required to achieve any given target position or rotation. I'd like to put a bounty on this question. Did you find anything?

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Guerrero-Survivor · Dec 27, 2015 at 01:03 AM

I haven't got the exact formula used by the Unity's physics engine, but my investigation of its behavior gave me the answer I was looking for. Given velocity (as Vector3) and drag (as float), the drag force is applied in Unity in the way descibed by the folliwing formula:

 float multiplier = 1.0f - drag * Time.fixedDeltaTime;
 if (multiplier < 0.0f) multiplier = 0.0f;
 velocity = multiplier * velocity;

How have I got it? Well, I wrote the script which computed the expected value of velocity's change (using this formula) at every fixed frame. I also wrote an another script measuring the value of the real velocity's change. I attached the both scripts to an object placed in the air. I also attached the rigidbody component to the object and disabled its gravity. Then during gameplay I gave a single forward impulse to the object's rigidbody. Both expected and real values of velocity's change were shown on the screen and updated every fixed frame, and they were always the same.

It's interesting that according to the abovementioned formula a rigidbody will be stopped immediately if its drag equals the number of fixed updates per second. For example, if we have 50 fixed updates per second, the drag being set to 50 or greater will prevent its rigidbody from moving.

I should also notice that in the real life the force of airdrag is non-linear and changes proportionally with the square of an object's velocity. Therefore, the Unity's formula is very rough. If you're making the game with the airdrag being the key factor of gameplay, you should set a rigidbody's drag to zero and apply the drag in your own script using the more accurate formula.

Comment
Add comment · Show 1 · 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 Incode · Nov 11, 2019 at 06:01 PM 0
Share

Whether or not this is the actual formula that Unity uses, it's pretty damn close. If you are trying to counteract drag when setting a velocity you can divide by (1.0f - drag * Time.fixedDeltaTime) and it should get you what you're looking for.

avatar image
0

Answer by sjhalayka · Nov 11, 2019 at 09:18 PM

This is the formula I used:

 Vector3 drag_vel = wind_vel - vel;
 Vector3 drag_accel = drag_vel * drag_vel.magnitude * 0.5f * air_density * drag_coeff * ball_cross_section / ball_mass;
 
 ...
 
 return gravitational_accel + magnus_accel + drag_accel;
     
Comment
Add comment · 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
0

Answer by FariAnderson · Jan 06, 2021 at 08:31 PM

According to NASA, Drag is related with Velocity^2, so the Drag number in Unity can be an approximation of the rest of this formula because according to this, in reality this number is not even constant because the Area towards the Velocity can change, and unity doesn't care about the shape of the object :)


alt text


NASA - Drag Formula


Comment
Add comment · 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.

Follow this Question

Answers Answers and Comments

6 People are following this question.

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

Related Questions

2D 360 degress platformer example needed 0 Answers

Is it elegant to use .drag to stop a rigidbody? 1 Answer

Quickly moving cubes fall through quad floor 3 Answers

Physics question 1 Answer

Rigidbody hover, bodies connected with joints should hover together. 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