Created: January 2011
Last Updated: January 2011
Original Author: Tony Huynh
Definition(s)
Collision Solid - any geometric representation of a collision boundary.
Types of Collisions
See http://www.flatredball.com/frb/docs/index.php?title=Tutorials:Introduction_to_Collision
Using Collisions
Remark: You do not need to add a collision solid to the ShapeManager class in order for collision detection to work. But if you do this for the purpose of displaying the visible solid on screen, then take note that attributes such as the visibility state of a collision solid should be changed after the solid is added to the ShapeManager in order for the attribute values to take effect.
Basic Routine
Create the collision solid.
Attach it to the entity so that it gets modified appropriately whenever the entity's position/rotation is modified. See the following sample code for attaching a collision solid to an entity:
// construct collision solid and attach it to an entity
CollisionSolid = new Circle();
CollisionSolid.Radius = COLLISION_RADIUS;
bool maintainRelativePosition = false; // that is, the solid will be teleported to the location of the entity upon attachment
CollisionSolid.AttachTo(mEntity, maintainRelativePosition);
See the following link for more information on using attachments: http://www.flatredball.com/frb/docs/index.php?title=Tutorials:Understanding_Attachments.
Apply collision logic in code. See the following link for an example on how to apply collisions (Note that you may need to read the source code to fully understand what is happening):http://www.flatredball.com/frb/docs/index.php?title=FlatRedBallXna:Tutorials:Entities_and_Collision