Chapter 8. Collision Detection and Physics

In this chapter, we will cover:

  • Using the built-in collision detection system
  • Using the built-in physics system
  • Using the ODE physics engine
  • Using the PhysX physics engine
  • Integrating the Bullet physics engine

Introduction

In a video game, the game world or level defines the boundaries within which the player is allowed to interact with the game environment. But how do we enforce these boundaries? How do we keep the player from running through walls?

This is where collision detection and response come into play.

Collision detection and response not only allow us to keep players from passing through the level boundaries, but also are the basis for many forms of interaction. For example, lots of actions in games are started when the player hits an invisible collision mesh, called a trigger, which initiates a scripted sequence as a response to the player entering its boundaries.

Simple collision detection and response form the basis for nearly all forms of interaction in video games. It's responsible for keeping the player within the level, for crates being pushable, for telling if and where a bullet hit the enemy.

What if we could add some extra magic to the mix to make our games even more believable, immersive, and entertaining? Let's think again about pushing crates around: What happens if the player pushes a stack of crates? Do they just move like they have been glued together, or will they start to tumble and eventually topple over?

This is where we add physics to the mix to make things more interesting, realistic, and dynamic.

In this chapter, we will take a look at the various collision detection and physics libraries that the Panda3D engine allows us to work with. Putting in some extra effort, we will also see that it is not very hard to integrate a physics engine that is not part of the Panda3D SDK.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset