Bradley Stephens
Bradley Stephens

Reputation: 21

Why do falling objects have incorrect terminal velocities in Unity?

I'm in the process of learning Unity and I've been experimenting with buoyancy and objects falling into water. I've setup a simple test scene with a plane to simulate the ocean and cubes of various shapes and sizes to test the implementation. I'm applying my own forces and I'm not using Unity physics for gravity, so I assume that's where the issue is coming in. If I use Unity gravity the object falls much slower than applying the force of gravity myself. Here's the setup: Cube Configuration Output Velocity

The cube reaches terminal velocity in about fifty meters of falling and tops out at -9.61376 unity units. My understanding of Unity is that the y value of the velocity vector is measured in units per second. I'm using all standard units in this project, so one would assume that means the object is falling at 9.6 meters per second. I'm using the standard gravity configuration of -9.81.

If we look at the expected terminal velocity (which we could easily just calculate online), we see the only unknown quantity in the calculation is Unity's value for atmospheric pressure and I don't see anywhere to configure it. Terminal velocity is reached when the drag experienced by an object is equal to the weight of the object. Drag is equal to air density (r) times velocity (v) squared divided by two, all that multiplied times the drag coefficient (Cd) and the cross sectional area (a). Something like this: Cd*(r*v^2/2)*a

We know the coefficient of drag is 1 for this object, we set it in Unity. We know the cross-sectional area should be 1 square meter (technically units). All that we're left with is density * velocity squared divided by two. We can solve for the terminal velocity of a 1 meter cube, by setting the weight equal to r*v^2/2 and solving for v (because, again, a body stops accelerating when drag equals weight). I believe the standard atmospheric density is 1.204 kg/m^3 at sea level. If we use that density and assume a weight of 1 kilogram we can solve for v as such, first we set weight to (9.81 * 1) or. 9.81 = 1.204 * v^2 / 2 19.62 = 1.204 * v^2 16.2956 = v^2 v = 4.036

That tracks with online calculations for the same parameters. So what gives Unity?

I tried to drop a cube in Unity and expected it to fall at a rate predicted by Newtonian physics, it didn't.

Upvotes: 1

Views: 330

Answers (1)

Bradley Stephens
Bradley Stephens

Reputation: 21

Did some further research into this question and it appears that Unity just doesn't "simulate terminal velocity". I found a post on the Unity forum from 2016 from a user employed by Unity, so I assume this is pretty accurate. I couldn't find the specific code in RigidBody to verify, but the in-game behavior does seem to indicate that the way gravity is calculated, mass is irrelevant.

Unity Forum Answer

I setup another test with cubes of various masses dropped from the same height with the same dimensions and drag and they do fall at the same velocity and impact at the same time, despite a 50% difference in mass.

So I guess the answer is, the way velocity is calculated in Unity physics the force of gravity is not proportional to mass (despite the fact that real life gravitational force = mass * acceleration of gravity). Not sure if there was a performance motivation for this approach, but this seems like a bug. Thinking about how to model drag, I get wanting to simplify it, but it's not a huge change to model it correctly. I did it by turning gravity off and applying my own forces to the rigid body and modeling drag with the correct formula and it approximates real life (heavier objects fall faster given the same surface area and coefficient of drag).

UPDATE

I'll leave my previous comments despite the fact that they may be incorrect. Reading more, I think it's fair to say Unity properly calculates the acceleration of gravity. I'm sure it's just a misunderstanding of the physics involved on my part, but I find it odd that objects of different masses but identical drag will fall at the same rate. Gallileo's Leaning Tower of Pisa experiment proved that objects of different masses but identical drag will fall at the same rate. I have a hard time rationalizing that result with Newton's Law of Universal Gravitation which states the force of gravity is equal to the product of masses of the two bodies divided by the distance between the bodies squared and the formula for terminal velocity which again is dependent on the mass of the falling object.

NASA Terminal Velocity

Upvotes: 1

Related Questions