Is there a way to determine which objects collided on a collision event? I see that the event happened, but can’t find a way to see which two objects were actually involved.
Thanks in advance for any help.
Is there a way to determine which objects collided on a collision event? I see that the event happened, but can’t find a way to see which two objects were actually involved.
Thanks in advance for any help.
There are two methods of listening for collision events. First is using a global collision handler. In this case the event object provides two properties, objec1 and object2, which reference the two objects involved in the collision. For example local function on_collision( event ) print( object1, object2 ) end Runtime:addEventListener( “collision”, on_collision ) The second method involves adding a listener to a body. Here the event object provides the “other” property, which references the other object in the collision. For example: function obj:on_collision(event) print( event.other ) end obj:addEventListener( “collision”, obj )
There are two methods of listening for collision events. First is using a global collision handler. In this case the event object provides two properties, objec1 and object2, which reference the two objects involved in the collision. For example local function on_collision( event ) print( object1, object2 ) end Runtime:addEventListener( “collision”, on_collision ) The second method involves adding a listener to a body. Here the event object provides the “other” property, which references the other object in the collision. For example: function obj:on_collision(event) print( event.other ) end obj:addEventListener( “collision”, obj )