Game Development Reference
In-Depth Information
When the game runs, we expect each one of the balls to move along the track, hit the cube, and
push it to some distance before both of them stop (or fall off the edge of the track). However,
we want restrict the movement of the balls as well as the cubes to x and y axes only, to prevent
the ball from falling from the side of the track. This is possible by setting the constraints of
the rigid body components attached to the balls as well as the cubes. What we need to do is to
freeze the movement on the z axis, and freeze the rotation around the y axis. The freeze of
the rotation is important for the cubes, in order to keep their orientation when they are hit by
the balls. The constraints of all rigid bodies of balls and cubes should look like Illustration
48.
Illustration 48 : Movement and rotation constraints of the rigid body
The four balls have different masses, but they have the same drag. Therefore, when the
game runs all balls start to move with equal velocity along the track. The effect of the mass
appears when a ball collides with the cube. The ball with greater mass is going to push the
cube for longer distance before both of them stop due to friction force. The result you are
going to see is similar to Illustration 49. This demo can be viewed in scene14 in the accom-
panying project.
Search WWH ::




Custom Search