Game Development Community

multiple calls to onCollision

by Scott Wilson-Billing · in iTorque 2D · 02/01/2010 (10:00 am) · 2 replies

Hi,

Is it possible for an object e.g. bullet to collide with another object e.g. alien more than once i.e. will I receive multiple calls to onCollision? The reason I ask is that my death function on the alien seem to (very occasionally) be called more than once by the same colliding object. Just wondered if it was a timing thing?

#1
02/01/2010 (12:43 pm)
There are some chances that onCollision will be called multiple times as a collision is still occurring. Try disabling the physics on an object when they start dying to prevent further collisions if you no longer need them for the dying object, or change its collision layer.
#2
02/02/2010 (5:52 am)
Thanks, I fixed it by setting my death flag as soon as the collision occurred and then tested the flag thereafter.