Sorry about the code i have been testing with multiple world.Query with and without Math.min(x, x2), Math.min(y, y2), Math.max(x, x2), Math.max(y, y2) and other different ways to test my logic

with the System.out.println statment - i can see player that is bits 2 and 4 getting called but not all the time... sometime only 2 or 4 is called when the player is in the Square.

So i'm trying to check :

1. player not in Area

2. player inn Area and is holding with inn the bounds of the Area

3. if the player have left the Area

Working on Enemy AI Steering and Sensors with rayCasting / world.QueryAABB

Any help would be gratefully

- Code: Select all
`public void getObjectsInRange(float x, float y, float x2, float y2) {`

world.QueryAABB(new QueryCallback() {

@Override

public boolean reportFixture(Fixture fixture) {

System.out.println("Fixture callback : " + fixture.getFilterData().categoryBits + " bodiesWithinArea : " + bodiesWithinArea.size);

if( fixture.getFilterData().categoryBits == 2 ||

fixture.getFilterData().categoryBits == 4 && !((bodiesWithinArea.size) > 0) ) {

System.out.println("Player withInn Erea!!");

if(!((bodiesWithinArea.size) > 0) ) {

bodiesWithinArea.add(fixture.getBody());

}

}

if( fixture.getFilterData().categoryBits != 2 && fixture.getFilterData().categoryBits != 4 ) {

System.out.println("We are not in Area!!");

}

return true; //keep going to find all fixtures in the query area

}

}, Math.min(x, x2), Math.min(y, y2), Math.max(x, x2), Math.max(y, y2));

}