Rigidbody Drag calculation

Hi,

I’m currently trying to develop a basic flight simulator but I can’t find anywhere what how a rigidbody is really impacted by his drag value.
Does it apply a force opposite to the velocity of the rigidbody as it should do ? or … ?

I don’t have find any response about this so I tried to put the drag value to 0.
And then apply my proper drag vector to the rigidbody but I have some strange results

Here is my code (maybe i have made a mistake ?):

// Drag is calculated using this formula http://en.wikipedia.org/wiki/Drag_equation
MyGameObject.rigidbody.AddForce(Vector3.Scale (MyGameObject.rigidbody.velocity.normalized, Vector3(-1,-1,-1))*Drag,ForceMode.Force);

Maybe you guys can help me ?

Thanks !

Hello,
Sorry for the late answer. I’m also currently searching for more details about Rigidbody’s “drag”. It seems this “drag” in Unity is taking the mass into account. So the formula would look like addForce(-velocitydragmass).

About your code, you should not normalized the velocity. Because the drag force is supposed to increase with the speed until it reach a stable speed.
And make sure your code is called from a FixedUpdate. Not an Update.

MyGameObject.rigidbody.AddForce(-MyGameObject.rigidbody.velocity*Drag);

Drag does not take mass into account.

–Eric

Eric,

I’ve just make some experiences with 2 rigidbodies, starting both with a velocity of 1.

function Start () {
	rigidbody.velocity = Vector3(1.0,0.0,0.0);
}

They both have a drag of 1.
One has a mass of 1, the other a mass of 100 and both rigidbodies move the same distance until they stop. (about 1 unit)

So the drag force of the heaviest rigidbody had to provide 100 times more force to stop the box at the same distance.
Then, it’s a bit confusing because the fact it takes mass into account make it looks like it ignores it…

That’s interesting. So then really, if you wanted the drag to stay the same with different masses, I guess you’d have to divide the drag value by the mass.