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)
c = c.Next;
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.