3
\$\begingroup\$

enter image description here

I've two Vector2 (A and B), i draw a line between them.

Is there a way to check if the line intersect the Box2D CircleShape? I need to a boolean output

\$\endgroup\$
1

1 Answer 1

2
\$\begingroup\$

You should use World#rayCast(callback, fromPoint, toPoint) to raycast the line.

callback = new RayCastCallback() {
    @Override
    public float reportRayFixture(Fixture fixture, Vector2 point, Vector2 normal, float fraction) {
        // Do stuff here
    }
};
world.rayCast(callback, point1, point2);
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .