- Home /

# Calculate parabolic initial velocity and angle?

Hi, I need to find the parabolic initial velocity and angle of projection in 2D. Given: initial point, final point, range, height, delta height.

As show in the figure the final point can be below or above the initial point. I have tried Itween Accurate Lob but does not give accurate projectile path in the end. Please help anyone?

I am using the following code rigth now but it does not include height parameter.

void Update() {

rigidbody2D.velocity = JumpVelocity (Camera.main.ScreenToWorldPoint (Input.mousePosition), angleInput); }

Vector2 JumpVelocity (Vector3 targetPosition, float angle) { var distanceVector = -transform.position + targetPosition; float height = distanceVector.y; distanceVector.y = 0f;

```
var distanceScalar = distanceVector.magnitude;
var angleInRadian = angle * Mathf.Deg2Rad;
distanceVector.y = distanceScalar * Mathf.Tan (angle);
distanceScalar += height / Mathf.Tan (angleInRadian);
float sqr = distanceScalar * (Physics.gravity.magnitude * 5) / Mathf.Sin (2 * angleInRadian);
sqr = sqr < 0 ? -1 * sqr : sqr;
var velocity = Mathf.Sqrt (sqr) * 100f;
return velocity * distanceVector.normalized;
}
```

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.