December 2004
Beginner
432 pages
10h 17m
English
One of the basic things that virtually all games have is a collision detection method. In this case, all you need to determine is whether a particular moveable object is colliding with the level. (See Listing 14.12.)
public bool HitTest(IMoveableObject obj, out Plane hitPlane) { // Default to an empty plane hitPlane = Plane.Empty; // This object hasn't left the level, has it hit a wall? IntersectInformation closestHit = new IntersectInformation(); if (levelMesh.Intersect(obj.Position, obj.Direction, out closestHit)) { // This will always return true since you will always be hitting the // outside of the level. Now you need to check to see if you're // close enough to really ... |
Read now
Unlock full access