I am trying to change my raycast, that used to get the closest fixture, so that it gets the closest that is not from category LEVEL0. I saw the following post:
viewtopic.php?f=3&t=4343
And looked at the solution, but it doesn't work for me. My RayCast class is like this:
Just like the one provided by Erin, but it doesn't work: it ignores the right bodies only sometimes, and sometimes ignores other bodies as well. The first if is called only in the right moments, I guess, and even though this happens. The regular objects collision works fine, so I don't think it is a problem with the categories setup. I tried other alternatives too: return -1 in the first if should just ignore this collision, but it doesn't work. Anyway, I think it is a Java (jBox2d within libGDX in my case) specific problem, so I am posting it here. Does anyone have a hint about this?
viewtopic.php?f=3&t=4343
And looked at the solution, but it doesn't work for me. My RayCast class is like this:
Code: Select all
private static class RayCast implements RayCastCallback {
Fixture f;
Vector2 point;
float fraction;
public RayCast() {
this.fraction = 1f;
}
@Override
public float reportRayFixture(Fixture fixture, Vector2 point, Vector2 normal, float fraction) {
if (fixture.getFilterData().categoryBits == Corpo.LEVEL0)
return 1f;
if (fraction <= this.fraction) {
this.f = fixture;
this.point = point;
this.fraction = fraction;
}
return 1f;
}
}Just like the one provided by Erin, but it doesn't work: it ignores the right bodies only sometimes, and sometimes ignores other bodies as well. The first if is called only in the right moments, I guess, and even though this happens. The regular objects collision works fine, so I don't think it is a problem with the categories setup. I tried other alternatives too: return -1 in the first if should just ignore this collision, but it doesn't work. Anyway, I think it is a Java (jBox2d within libGDX in my case) specific problem, so I am posting it here. Does anyone have a hint about this?