Springs

We briefly introduced springs in Chapter 16, Springs and Joints. We saw how we can use springs to create soft bodies like cloth. In this section, we will explore other uses of springs.

Collision resolution

If we know the collision point, depth, and normal, we can use springs to resolve the collision. This method works by placing a temporary spring at the point of contact that will push objects apart in the direction of the contact normal. The spring should exert just enough force to push the two bodies apart.

The force that the spring exerts on the rigid bodies is called a penalty force. Due to this terminology, using springs to resolve collisions is often called penalty based collision resolution; the following image demonstrates this:

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.