Multi Elemental Physics Bodies

Is there any way to tell which part of a multi elemenatl physics body has collided with. eg.

physics.addBody( obj, {shape = {} },{shape = {} } ) obj:addEventListener( "collision", function (event)     -- Which of the two bodies has collided? end )

Regards, Lemon

You can read up on this at the Corona docs (http://docs.coronalabs.com/daily/guide/physics/collisionDetection/index.html). The properties are simple:
[lua]
event.selfElement

event.otherElement
[/lua]
event.selfElement will be the index of the body element that collided; if it’s the first element, it’ll be 1, if it’s the second, it’ll be 2, etc., etc., etc.

event.otherElement is the same, but it’s the other object’s colliding element.

  • Caleb

ah thanks, must have missed that part

No problem :slight_smile:

  • Caleb

You can read up on this at the Corona docs (http://docs.coronalabs.com/daily/guide/physics/collisionDetection/index.html). The properties are simple:
[lua]
event.selfElement

event.otherElement
[/lua]
event.selfElement will be the index of the body element that collided; if it’s the first element, it’ll be 1, if it’s the second, it’ll be 2, etc., etc., etc.

event.otherElement is the same, but it’s the other object’s colliding element.

  • Caleb

ah thanks, must have missed that part

No problem :slight_smile:

  • Caleb