What is the best way to find out if a body or fixture was clicked?
I have this QueryAABB thing setup to simply print “here” when I click on a body, however it seems to be well…very inaccurate.
I can click practically 500 pixels to the right of my body and it says I have clicked on it, anyone got an idea if I am doing this wrong?
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
Vector3 touchPos = new Vector3(screenX, screenY, 0);
universe.game.b2dCam.unproject(touchPos);
universe.bFactory.getWorld().QueryAABB(new QueryCallback() {
@Override
public boolean reportFixture(Fixture fixture) {
System.out.println("here");
return false;
}
}, touchPos.x - 1, touchPos.y - 1, touchPos.x + 1, touchPos.y + 1);
return true;
}