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

Close call

Topics: User Forum
Sep 28, 2012 at 11:24 PM

I want to detect when two bodies almost collide, without actually colliding (to create a 'close call' effect).

What would be the easiest/optimal way to do this? Is there something similar to the OnCollision method that I could use? I'd greatly appreciate any advice (fairly new at game development here)!


Sep 29, 2012 at 10:20 AM

Attach an additional fixture to the body and set it as sensor (IsSensor=true). Make it bigger that the main fixture by scaling the vertices of the main while keeping the same center and you'll have a bounding perimeter where you can detect collisions.

Check this tutorial for more info (Box2D): 

Sep 30, 2012 at 12:34 AM

Thanks a lot jerrysb! I was a little afraid of using a new fixture for performance reasons, but I'll definitely give using sensors a try.