This project has moved and is read-only. For the latest updates, please go here.

Body.OnCollision continuous execution

Topics: User Forum
Oct 13, 2011 at 11:44 PM

Wondering if there is a way to cause OnCollision to continuously fire while another body intersects?  I am basically trying to make "gravity zones" out of sensor bodies that impose a force on any body that comes in to contact with them.  I'm trying to avoid handling it externally from the engine if possible, in order to keep overhead down.


Oct 14, 2011 at 9:14 AM

When OnCollision is triggered, you set a flag like

colliding = true;

Then on the OnSeparation, you set

colliding = false;

Then, in your update method:



   //Do whatever you want


Oct 14, 2011 at 5:23 PM

Yeah, I was expecting that would be the solution.  I was hoping I could avoid it, but not a big deal.

Oct 16, 2011 at 1:46 AM
Edited Oct 16, 2011 at 1:47 AM

Got it all going.  Thanks for the help.


The result:

Oct 18, 2011 at 11:17 AM

Glad it helped. The video looks very nice, and your project seems quite interesting, love the tile level editor.

Nov 1, 2011 at 6:24 PM
Edited Nov 1, 2011 at 8:19 PM

You can also return false in OnCollision event so next time when the world is updated event will be fired again.