I am working on a simple bowling game using AwayPhysics and would like to ask if my approach on collision detection could be improved further:
1. I want to detect the event when the bowling ball hits a pin (both of them are of type AWPRigidBody)
2. I added an event listener to the pin e.g.
_physicsWorld.addRigidBody(pinBody);
pinBody.addEventListener(AWPEvent.COLLISION_ADDED,collisionDetectionHandler);
protected function collisionDetectionHandler(event:AWPEvent):void
{
trace(“collision detected”);
if (event.collisionObject == ballBody)
{
trace(“collision detected with ball”);
}
}
3. At the start of the game, the pin is on the ground. The collision event is always fired at every timestep because the pin is ‘colliding’ with the ground.
4. My question is : It seems computationally expensive to keep firing the collision event at every timestep just because the pin is on the ground. Is there any way to stop this from happening and only fire the collision event when the ball hits the pin?
Thank you for your help!