How do i calculate a projectiles force by the distance to target?

Hello!
I need to calculate how much force i need to apply to a projectile, to hit a target.

I have an arcing projectile, which is shot towards the closest player using Transform.LookAt(); and Vector3.Distance();,
but I can’t figure out how I should calculate to make the projectile always hit it’s target, no matter what distance is between the “instantiator” and the target.

Here’s a quick video demonstrating it in my game:

Youtube Video

As you see, it doesn’t calculate it properly.

The code:

			time -= Time.deltaTime;

			distanceToTarget = Vector3.Distance(transform.position, player.transform.position);

			if(time <= 0)
			{
				snowballInstance = Instantiate (spawnObject, transform.position + transform.up, transform.rotation) as GameObject;  
				snowballInstance.rigidbody.AddForce(transform.forward * 250); 
				snowballInstance.rigidbody.AddForce(transform.up * distanceToTarget * 47.5f); 

				time = maxTime;
			}

Thank you for your attention!

Here are some helpful links:

-Calculate a Rigidbody trajectory - Unity Answers

-Calculating ball trajectory in full 3d world - Unity Answers

You can also try researching “Parabola”.