I have a problem and I'm not smart enough to work out a solutions.
I want to achieve a throw, a bomb between two points, and so it travels as an arc from point A, to point B. Point B is known and the bomb must land on point B
if the distance between the two positions AB is dynamic and the horizontal distance changes, the vertical distance may also change.
How can we know the initial vertical velocity in which to throw the object to make it art exactly on to position B?
How can I calculate it so my bomb moves in an arc from whatever point A is, so that it hits point B in an ARC. I have no idea, using other istes this is what I tried, i tried at least...then realized I have no idea for how long to run the loop for, and have no idea how to hit point b exactly.
tagetTilePosition is a vector ( 0 , 0 )
double startX = bombPosition.x; // initial position
double startY = bombPosition.y; // of the object
float angle = 45.0f * Mathf.Deg2Rad;
const double g = 9.8; // gravity (meters/s^2)
double velocity =20.0;
double Vx = velocity * Mathf.Cos(angle); // x (horizontal) component of velocity
double Vy = velocity * Mathf.Sin(angle); // y (vertical) component of velocity
Vector2 distance = ( bombPosition2 - tagetTilePosition );
//guessing
double endTime = ( distance.x + distance.y ) / velocity ;
for(double wait = 1; wait <= endTime ; wait += 1f)
{
/*
float v_v;
double g = 9.8f
float s;
float t = wait;
s = bombPosition.y;
t = d / v_h
v_v = (0.5f * g * (t * t) + s) / t;
*/
double t = wait;
double x = startX + Vx * t;
double y = startY + Vy * t - 0.5 * g * t * t;
bombPosition.x = (float) x;
bombPosition.y = (float) y;
// bombPosition.x = centre.x += ( 60 * Mathf.Cos ( (float) wait ) );
//bombPosition.y = centre.y -= ( 60 * Mathf.Sin ( (float) wait) );
bomb.transform.position = bombPosition;
}






