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\$
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\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.