Hi,
i have read that to find a trajectory, we can use this equation with pointA and pointB (AB = distance) :
AB = v0^2 sin2a / gravity
i am looking only for the angle, as i will have a constant speed to throw the ball, so depending on the distance, how could i find the right angle?
I found this thread : How to make enemy Cannonball fall on moving target position. - Questions & Answers - Unity Discussions
but the function uses a different velocity compared to the angle, i would need to use the same velocity. So i would like to find the angle automatically when we have the distance, so that the ball can start coming down at the middle of pointA and pointB.
Is the equation above correct to find this in a 3d environment?
If so, i thought i could calculate it like this : sin2a = AB * g / v0^2
but then i am not quite sure how to go on to only find “a”, should i calculate the result of AB * g / v0^2 , then :
var distArc : float = Vector3.Distance(to.position, thisTransform.position);
var sin2a : float = (distArc * -1) / (speedArc*speedArc);
Debug.Log(Mathf.Asin(sin2a));
and divide the total by 2?
The result in the Debug.Log is something like 0.2, 0.4, until it reaches the target (i only tested with a simple addForce in the forward direction), i am not sure if i am following a wrong way or not…
Thanks