I'm trying to calculate what angle to hit a pool ball and predict where ball will go to.. I thought target ball should move within a normal direction.. but it moves on totally different direction
RaycastHit2D hit = Physics2D.CircleCast(cue.position, _radius, dir, 100f, ~(ignoreLayer));
if (hit.collider != null)
{
Debug.DrawRay(hit.collider.transform.position, -1f * hit.normal,
Color.green, Time.fixedDeltaTime);
}
Here is result:
Set velocity
rb.velocity = dir * force;
Result:
How to find exact move direction, Thanks
Edit:
I have tried Double Radius Casting this works only half way.. only when ray inside inner circle
I suppose this is just a limitation of the physics engine, which is optimized for speed and use in games, and is not so exact.
Trying this myself in a simple 2D scene, I found that if I set the friction to 0.01 and the bounciness to 1.0, it works the way I would expect. (in Unity 2020.1)
In the small sample scene I added, there is a ball aiming at another so that the resulting angle should be 45 degrees. And after setting the phyics-mat to the properties with friction 0.01 and bounciness 1.0, the resulting angle is as expected.
With the default-mat I get the same behaviour you described.
Did you forget to assign the physics materials?
Have you single-stepped to the point of contact and checked if the aiming is correct?
my sample project trying this