Turning off collisions in the physics world

I have several unique objects on screen.

They can ALL collide with each other.

They are propelled across the screen using linearVelocity.

At the moment any object that collides with another is removed and destroyed up on contact.

All working fine.

What I want to do is delay the removal of the collided objects so when they contact you can visually see the collided objects interact with each other.

I need the objects collision ability to be inactive so when the collided object is moving after contact it dosnt register a collision with any other object.

Now I looked at isBodyActive but this obviously just removes the object from the physics world and the object is inanimate.

I looked at using event.contact but this also is not suitable.

isHitTestable would be great but again wouoldnt work.

So basically when the objects collide I need to stop them registering collisions but keep them in the physics simulation.

Any ideas? set a flag perhaps somewhere ? but them what to call using the flag etc hmmm

thank you

I’m not sure but maybe try collision filtering? … https://docs.coronalabs.com/daily/guide/physics/collisionDetection/index.html

Hi @bubblebobble,

One potential solution is this:

  1. Upon collision, set the object to a sensor type (if it’s not already). This will keep it active and moving in the physics world, and it will still register collisions.

  2. At the same time , set some custom property on the object (name of your choice) like “object.hasCollided = true”.

  3. If another collision occurs (or actually, in case #1, so if any collision occurs), check if the “hasCollided” property is true. If it is, then simply return (exit) out of the collision handling function.

You could also just use the inherent “.isSensor” property instead of setting a custom property, but only if the objects are not sensors before their initial collision.

If this sensor setup won’t work, then you can use event.contact (I’m not sure why you dismissed that approach, because it should do exactly what you need it to do).

Brent

@Brent,

good solution, simple enough too, I will get on with it and update the thread as necessary.

Thanks

I’m not sure but maybe try collision filtering? … https://docs.coronalabs.com/daily/guide/physics/collisionDetection/index.html

Hi @bubblebobble,

One potential solution is this:

  1. Upon collision, set the object to a sensor type (if it’s not already). This will keep it active and moving in the physics world, and it will still register collisions.

  2. At the same time , set some custom property on the object (name of your choice) like “object.hasCollided = true”.

  3. If another collision occurs (or actually, in case #1, so if any collision occurs), check if the “hasCollided” property is true. If it is, then simply return (exit) out of the collision handling function.

You could also just use the inherent “.isSensor” property instead of setting a custom property, but only if the objects are not sensors before their initial collision.

If this sensor setup won’t work, then you can use event.contact (I’m not sure why you dismissed that approach, because it should do exactly what you need it to do).

Brent

@Brent,

good solution, simple enough too, I will get on with it and update the thread as necessary.

Thanks