Unity werfen mit hhe

Vector3 CalculateLaunchVelocity(Vector3 from, Vector3 to, float height) 
{
	float displacementY = to.y - from.y;
	Vector3 displacementXZ = new Vector3(to.x - from.x, 0, to.z - from.z);
	
	Vector3 velocityY = Vector3.up * Mathf.Sqrt(-2 * gravity * height);
	Vector3 velocityXZ = displacementXZ / (Mathf.Sqrt(-2 * height / gravity) + Mathf.Sqrt(2 * (displacementY - height) / gravity));
	
	return velocityXZ + velocityY;
}
Clever Cow