one stop for all game coders..
| Collision Detection |
|
|
| Written by CR Team | ||||||||||||||||||||||||||||
| Monday, 18 May 2009 00:00 | ||||||||||||||||||||||||||||
|
Collision detection is a key component in creating a real world replica in the world of games. Writing your own collision detection system can be really painful and involves lot of mathematical calculations.So why waste your time writing something new when you have a lot of physics engines giving you out of the box support ( Ageia, Havok etc..) We have compiled a sample wrt Adobe Director 11 and Ageia physics ( link below ) . Please refer wiki for more details on Collision detection. Collision detection can be achieved with 3 step process : 1.Enable Collision between rigid bodies. Use EnableCollision(rbA,rbB) 2.Enable Collision Callback for the rigid bodies. Use EnableCollisionCallback(rbA,rbB) 3.Register collision callback handler for the collision. This is the function that will be called when collision is detected between 2 rigid bodies. Use registerCollisionCallback(collisionfunction) Write code to handle the logic , what has to happen when the rigid bodies collide.
NOTE: Remember, not to delete any rigid bodies inside the collision handler!! , Instead you can keep track of the models to be deleted in an array/list and then delete the same(delete rigid body first, then the models ) after the collision reports inside the handler function is taken care of. Trying to delete rigid bodies when you are inside the collision handler can result in unknown behaviors !! Also make it a habit to set the mass of every rigid body that you create, this saves you from breaking your head when you see strange things happen in 3d/physics world which were not supposed to happen that way :) …
|