Jump to content

Physics: How does unity calculate drag?


Andy Gilbert
 Share

Recommended Posts

Hi, ok i dont use unity but whilst researching more into drag and angular drag online i found that unity has these two properties built in as standard into its physics engine which confuses me because.

 

Everywhere i look into calculating drag i come accross the standard equation: D = Cd * A * .5 * r * V^2 where you need to know, air density, a drag coefient & area of body. Yet it looks like in unity you can add an object and apply angular and motion drag without any of the above properties being inputted, so how can it be done?

 

I ask because i want to do the same in leadwerks, i want to add some simple drag to my bodys both angular and velocity without having to touch air density or coeffienents.

 

Update: found this on their forum (i didnt realise unity used phyx)

dragForceMagnitude = velocity.magnitude ^ 2 * drag; // The variable 
dragForceVector = dragForceMagnitude * -velocity.normalized

 

 

Thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

Everywhere i look into calculating drag i come accross the standard equation: D = Cd * A * .5 * r * V^2 where you need to know, air density, a drag coefient & area of body. Yet it looks like in unity you can add an object and apply angular and motion drag without any of the above properties being inputted, so how can it be done?

I'm guessing that their simulation of drag is a very simple one and makes a lot of assumptions. I suspect you might wait some time before anyone answers this post Andy, you might be better just experimenting or posting on a physics based forum / thread where your more likely to attract the people who might be able to shed some light on this.

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

For what is it used then ?! ... you should forget about the "correct" way in computer games since its stated as being "allways" to expensive to calculate - e.g. if you want/can use joints controll its rigidity and let it add up to object mass ... but you know what i mean.

AMD 64 X2 Dual 5k - 4GB - XFX GForce9800GT - nv196.21 - WinXP Sp3

zBrush4R2 - Silo2Pro - Unwrap3DPro - Gile - MaPZone2.5

 

adv_banner-april2012_720x150_tex01.png

 

Xxploration FPS in progress ...

Link to comment
Share on other sites

Hi Flachdrache, i just want to add some drag and angular drag to my rigid bodies.

 

Im not sure how the method you describe works, coiuld you explain more?

 

And you have completly lost me on your 2nd post.

 

Thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

Hi Andy,

 

I simulated drag on a vehicle that I was doing in Leadwerks some time ago.

 

The equation in your first post is correct. You just have to assume and approximate a lot of the variables.

 

D = Cd * A * .5 * r * V^2

 

Cd - Look up some standard coefficients of drag and pick one

A - estimate the average facinga area of your model. Approximate is ok remember.

V - well you can get that. Its simply the velocity of your object.

r... ah remind me what this one is

 

anyway all you have to do is get the opposing vector to the direction of travelt (i.e. a nomralized and negative velocity vector) and then apply the force D that you get from the approximate equation to your object.

 

Now if you don't get a good result.. play around with Cd & A values till it looks right.

 

P.S. I like the screenshot of your game on your blog. You're getting a nice natural look there :(

STS - Scarlet Thread Studios

AKA: Engineer Ken

 

Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now!

Link to comment
Share on other sites

Hey - iam puzzled as well since its a nice to have ... the guess i made was geared forward to gamelibs implementation which i guess just hooks the bodys mass center to a joint ... momentum usually will do the rest for us imho. I mean, its a physics lib if using joints all we can control is joint stiffness afaik.

 

PS: i just saw your "The good news about computers ..." quote ... dont mind, i just meant that we have to fight for our hard disk drives now - or we will get pre-configured. (censored)

 

@Engineer Ken - dont you just try to outsmart newton lib ?!

AMD 64 X2 Dual 5k - 4GB - XFX GForce9800GT - nv196.21 - WinXP Sp3

zBrush4R2 - Silo2Pro - Unwrap3DPro - Gile - MaPZone2.5

 

adv_banner-april2012_720x150_tex01.png

 

Xxploration FPS in progress ...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...