Physics System Update

Now that we have a way to generate collision manifolds for colliding objects and a way to apply impulses to rigidbodies, we must make some modifications to the physics system to actually use these features. Most of this work will consist of modifying our physics loop, but we also need to add a few class variables.

As we are applying gravity to objects resting on each other, we might experience sinking. Sinking simply means that objects that should rest on top of each other sink through each other. We can fix this using Linear Projection. To perform linear projection, when a collision has happened, we will move both the objects a little along the collision normal. This slight adjustment to position will fix sinking problems ...

Get Game Physics Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.