Hello there
How to Check if a body is completely within another body that has the isSensor set to true?
The code below only checks if a those 2 bodies have contact.
How to Check if a body is completely within another body that has the isSensor set to true?
The code below only checks if a those 2 bodies have contact.
Code: Select all
package
{
import Box2D.Dynamics.b2ContactListener;
import Box2D.Collision.b2ContactPoint;
public class ContactListener extends b2ContactListener
{
public function ContactListener()
{
}
override public function Persist(point:b2ContactPoint):void
{
if(point.shape1.GetBody().GetUserData() is CrateActor && point.shape2.GetBody().GetUserData() is BoxSensorActor)
{
trace("Crate is where it should be!");
}
else if(point.shape1.GetBody().GetUserData() is BoxSensorActor && point.shape2.GetBody().GetUserData() is CrateActor)
{
trace("Crate is where it should be!");
}
super.Add(point);
}
}
}