0
\$\begingroup\$

I am making a game with libGDX (with box2d) in which you drag and aim one circle body at another then release to fire. I would like to be able to predict the path of the second circle based on the aim of the first. very like 8 ball pool when aiming your shot.

I have been playing around with various trig solutions but i just cant get it to work at all! I have also been reading about ray casting in which I would cast a ray from the center of the first circle body in the direction i am aiming. this would tell me where the ray intersects the second circle body (if it does so) but it would not be correct as the circle fixture would not actually collide where they ray does because it obviously has a radius.

Is the trig solution the correct path or is there a simpler way to do this?

\$\endgroup\$
1
  • \$\begingroup\$ Google Physics and Momentum then work on some example problems. I'll bet you even find some example pool ball collision examples. \$\endgroup\$
    – Dunk
    Commented Nov 21, 2014 at 20:53

1 Answer 1

0
\$\begingroup\$

The easiest solution I found was to attach a sensor with a radius the sum of the two radii to the second circle and a RayCast callback returning the fraction and filter for just sensors. The collision point is where the center of the first circle will be upon contact. a vector between the contact point and the center of circle two gave me the predicted path of the circle.

\$\endgroup\$

You must log in to answer this question.

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