Properties
Every physics object has a set of properties that determine how it interacts with the world and other objects in that world. These are things like friction, gravity, and restitution (bounciness). In this article we'll cover what each one does.
The properties we'll be covering in this article are highlighted in the image above.
Tip
The properties just above and below those are also related to physics and are covered in the Enabling Physics article and Collision Shapes article, respectively.
Density
Density refers to how heavy something is for its size. When two objects collider, their densities are taken into account in order to determine how much force they exert upon one another. Wehn designing a scene with a bowling ball and a beach ball, the bowling ball would be assigned a much higher density even though it's the smaller of the two.
As you can see, with a higher density the bowling ball is barely affected by the much less dense beach ball.
If we swap their densities, you'll see very different behavior.
Restitution (Bounce)
Simply put, restitution is how bouncy an object is. The higher the value, the bouncier it is.
- bowling ball (left): very low restitution, no bounce
- kickball (middle): high restitution, very bouncy
- beachball (right): medium restituion, somewhat bouncy
Friction
Friction affects how much an object resists sliding across a surface. In the example below, the front cube has low friction and slides quickly down the ramp. The cube in the back has higher friction, so it moves much more slowly.
Note
When calculating velocity, the friction of both surfaces is taken into account. In the example above, if the ramp had no friction (like ice) both cubes would slide off the ramp much more quickly than in this example.
Linear Damping
Linear damping gradually slows an object’s movement, like invisible air resistance. In the example below, both balls are identical except the one on the left has higher damping. It falls and bounces more slowly because it loses more speed on the way down and up.
Angular Damping
Angular damping works the same as linear damping except that it's applied to an objects rotation rather than movement. It's like an invisible force making it harder for the object to rotate, similar to how closing your fist around a pencil makes it harder to spin it in your hand.
In the example below, the near ball has no angular damping and thus rolls faster and farther because it can rotate more freely.
Gravity
Just as in the physical world, gravity determines how quickly an object will fall. Unlike the physical world, in a physics engine you can control how much gravity effects individual objects. From left to right, the balls are set to 10%, 50%, and 100% gravity causing them to fall at different rates.
Getting the Right Feel
Every property on each physics object goes into calculating the next frame in the simulation. So while you may be changing one property hoping to get a specific result, you may end up having to adjust other seemingly unrelated properties to get the result you want. Turning up linear damping works against gravity, as does making an object more dense. Denser objects will bounce less than lower density objects with the same restitution.
It may take some time to get objects to behave and feel exactly as you want them to - that's just the process. Enjoy the ride
Physics Lua API
All of these values, and more, are exposed by our physics API where you can read and modify them as well as add impulses. If coding is your thing, you can check out our API reference here.