Collision Detection between bowling ball and bowling pin

Software: Away3D 4.x

niczy, Newbie
Posted: 07 September 2012 10:26 AM   Total Posts: 7

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!

   

macaan, Newbie
Posted: 08 September 2012 01:06 PM   Total Posts: 30   [ # 1 ]

you can use the method addRigidBodyWithGroup, then you can specify which bodies should collide with each other. in your case the pins should just collide with the ball…
there is one demo in the awayphysics examples on github

https://github.com/away3d/awayphysics-examples-fp11/blob/master/src/CollisionFilterTest.as

   

niczy, Newbie
Posted: 10 September 2012 07:46 AM   Total Posts: 7   [ # 2 ]

Thanks macaan! I will take a look at the demo and try it

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X