A Sensor’s ContactList Keeps Old / Ignores New Contacts, When That Contact Is still.

Topics: Developer Forum, User Forum
Jan 10, 2014 at 12:55 PM
Okay this is a hard one to explain so I’ll try my best.

Basically every time my enemy class updates, it runs a SightCone Sensor Contact List test, so this is every single frame it checks for all the possible contacts in it’s sensor.

What I’m finding is that if I’m moving my player character around, the contact list updates perfectly, when the player is in the enemy’s sight, it’s true, when it is out of sight its false,

However if I keep my player still, The contact list always ignores it.

Here is a video showing the behaviour. (the true and false flag is in the top left.)

Here is the code I have. Basically in the Enemy’s update method I run the check (the sightcone is a supplemental body within the enemy class that follows the position and rotation of the enemy body every frame.)
List<Body> coneClip = GetBodiesInContactWithBody(SightCone.Body);

private List<Body> GetBodiesInContactWithBody(Body body)
            var bodiesInContact = new List<Body>();
            var c = body.ContactList;
            while (c != null && c.Next != null)
                if (c.Contact.IsTouching)
                c = c.Next;
            return bodiesInContact;
I am not sure why this is happening. I don’t know why the contact list isn’t seeing the player, even though the body is still, it still exists, has a shape and position, and 100% exists in the physics world.

Truly hope you can help.
Jan 11, 2014 at 3:40 PM
have you set SleepingAllowed to false?
Jan 12, 2014 at 12:58 PM
Edited Jan 12, 2014 at 1:05 PM

that solved it DarkPrisma. i had no idea that bodies were set to sleep automatically by the engine. figured any body in the simulation was always awak until the user chose to put it to sleep.

thanks so much for your help!!!