Detect collision between specific / unique objects.

Hello 

I am stumped, to say the least.

I often find myself coming here for advice with rather simple things, that i just cannot think of myself. =\

I am in need of a way to detect a collision between 2 specific objects.

To be more clear, i need a way to filter collisions with objects that aren’t the player.

i.e. When the player collides with an object, It detects it and moves on to execute a command.  If two other objects collide into eachother (and not the player), nothing happens.

Best thing i can say to imagine is powerups bouncing around.

We don’t want the powerups triggering unless it collides with “only” the player(s)

I’m not sure how to go about filtering out the objects, as there are quite a few different bodies in my app at all times.

Thanks in advance!

See this page of the docs – there’s everything you’re looking for:

http://docs.coronalabs.com/guide/physics/collisionDetection/index.html

You can name your objects and then check by name inside the collision event (if event.other.myName == “enemy” then foo) or you can create collision filters (towards the bottom of that page).

 Jay

Hmm.  I was thinking that i had sent a reply to this.  

It made a world of difference.  I never thought about going by names, rather than the filter.

It worked like a charm.

Thanks a ton

Tyler

See this page of the docs – there’s everything you’re looking for:

http://docs.coronalabs.com/guide/physics/collisionDetection/index.html

You can name your objects and then check by name inside the collision event (if event.other.myName == “enemy” then foo) or you can create collision filters (towards the bottom of that page).

 Jay

Hmm.  I was thinking that i had sent a reply to this.  

It made a world of difference.  I never thought about going by names, rather than the filter.

It worked like a charm.

Thanks a ton

Tyler