Hey Everyone,
I used this tutorial to calculate the trajectory of a projectile.
And it works like a charm, you can adjust the length and the hight,
but I wonder if its possible to adjust the speed of the projectile?
I want to add some extra force to my throw.
Any help in the right direction would be great.
Kind regards
void Update () {
if (Input.GetButtonDown ("Jump"))
{
Launch ();
}
}
void Launch()
{
gravity = Physics.gravity.y;
Plunger.useGravity = true;
Plunger.velocity = CalculateLaunchVelocity ();
}
Vector3 CalculateLaunchVelocity ()
{
float displacementY = target.position.y - Plunger.position.y;
displacementY = displacementY;
Vector3 displacementXZ = new Vector3 (target.position.x - Plunger.position.x, 0, target.position.z - Plunger.position.z);
displacementXZ = displacementXZ;
Vector3 velocityY = Vector3.up * Mathf.Sqrt (-2 * gravity * h);
Vector3 velocityXZ = displacementXZ / (Mathf.Sqrt(-2*h/gravity) + Mathf.Sqrt(2*(displacementY - h)/gravity));
return velocityXZ + velocityY;
}