Using 4 collision planes as world boundary

Feb 27, 2008 at 6:55 PM
Edited Feb 27, 2008 at 6:56 PM
Hi FretBoardofFury,

I have been trying to build 4 collision planes to prevent objects from moving out from the world. However, this code causes all rigid bodies' position to be NaN. What am I doing wrong here?

// Create the world boundaries plane
            // in order of left, front, right and back order
            for (int i=0; i < 4; i++)
            {
                this.worldBoundaries[i] = new CollisionPlane();
                this.worldBoundaries[i].CategoryFlags = 1;
                this.worldBoundaries[i].CollisionFlags = 1;
            }
 
            // Left plane
            this.worldBoundaries[0].Normal = Vector3.Right;
            this.worldBoundaries[0].Distance = (environment.GameTerrain.Width);
 
            // Right plane
            this.worldBoundaries[1].Normal = -Vector3.Right;
            this.worldBoundaries[1].Distance = -(environment.GameTerrain.Width);
 
            // Front plane
            this.worldBoundaries[2].Normal = Vector3.UnitZ;
            this.worldBoundaries[2].Distance = -(environment.GameTerrain.Height);
 
            // Back plane
            this.worldBoundaries[3].Normal = -Vector3.UnitZ;
            this.worldBoundaries[3].Distance = (environment.GameTerrain.Height);
.....
    for (int i = 0; i < 4; i++)
            {
                CollisionDetector.Detect(obj, this.worldBoundaries[i], context);
            }
 
 
 
            CollisionDetector.Detect(obj, this.collisionTerrain, context);
            CollisionDetector.Detect(obj, this.waterPlane, context);
Coordinator
Mar 3, 2008 at 1:32 PM
I think you need to make all your plane distances negative. I'll check when my DBP contest code when I get a chance - I did the same thing there.