Chapter 4. Physics and the Environment

So far we have chosen not to mess with the physics engine, but we are about to change all of that. In ShiVa, we specify that an object will have to play by the rules of physics by attaching a dynamic controller to the object. The same goes for sensors and colliders. In this way, we can get some robust behavior by adding these characteristics as needed.

In this chapter, we will discuss the following:

  • Sensors and how they can be used to do things like trigger effects in the environment and register collisions
  • Dynamic objects such as asteroids, and the ship, and what it means to tag an object as dynamic
  • Colliders and what characteristics they add to an object

Sensors

Sensors are handy to determine when other objects pass through an area; however, the objects must have a sensor applied to them as well, in order to trigger sensor events. We can then trigger events or effects in our scene to add greater interactivity. Sensors show up in the Scene Viewer window as purple boxes or spheres and their boundaries are configurable. We will use sensors to spawn asteroids that will fly toward the ship and add a little extra challenge. We will also use sensors to tell us when the ship hits stationary objects such as the tunnel. Where sensors allow us to trigger events based on collisions, dynamic objects use collisions to show physical interactions between objects in a game.

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

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