Can you please help me to understand,
How can i STOP a raycast, when it hit a wall?
Let's say that :
$==player, #==wall, %==Enemy, RayCast == ------.
And i have this level:
___________________________
#
#
% -----#---$---
___________________________
How can i stop the enemy shooting at me in this kind of situation?
How can i just stop the raycast for "to see what there is after the wall fixture"?
For now I just get them both:
RayCastCallback callback= new RayCastCallback() {
@Override
public float reportRayFixture(Fixture fixture, Vector2 point, Vector2 normal, float fraction) {
if (fixture.getFilterData().categoryBits == Application.PLAYER){
return fraction;
}
if (fixture.getFilterData().categoryBits == Application.ENEMY){
return fraction;
}
return 0;
}
};
world.rayCast(callback, p1, p2);
So it's the fraction that can achieve that? if so, how?
Thanks so much!
with this approach, it's works for what i need:
So when i print the type:
The result will be to STOP a raycast, when it hit a wall.
Well, not really to stop, in other words, just to get the result that i need which in this case is NOT to print the player, when the wall comes first.
From the docs, about the return: