Chapter 10. Implementing Collision Response

In this chapter, we’ll show you how to add a little excitement to the hovercraft example discussed in the preceding chapter. Specifically, we’ll add another hovercraft and show you how to add collision response so that the hovercraft can crash into each other and bounce off like a couple of bumper cars. This is an important element for many types of games, so it’s crucial that you understand the code that we’ll present here. Now would be a good time to go back and review Chapter 5 to refresh your memory on the fundamentals of rigid-body collision response since we’ll use the principles and formulas discussed there to develop the collision response algorithms for the hovercraft simulation. In Chapter 8 you saw how to implement linear collision response for particles, and now we’ll show you how to handle angular effects.

To start simply, we’ll first show you how to implement collision response as if the hovercraft were a couple of particles just like those in Chapter 8. This approach uses only linear impulse and does not include angular effects, so the results will be somewhat unrealistic for these hovercraft; however, this approach is applicable to other types of problems that you may be interested in (for example, billiard ball collisions). Plus, taking this approach allows us to show you very clearly the distinction between linear and angular effects. Including angular effects will make the simulation much more realistic; when the hovercraft ...

Get Physics for Game Developers, 2nd Edition 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.