# Predicting Where a Rigidbody will land?

I did a search both on this forum and a google search of the web and came up with a lot of math, but I’m still lost.

Simply put, if I have a ball (a rigidbody) currently in flight (has a rigidbody.velocity and position), what would be the math to help me predict where (position : Vector3) it will land on the level ground? Gravity is Physics.gravity and the ground is level with it’s position.y = 0.

To make it simpler, I have drag set to zero. If anyone has any suggested solutions, I would so appreciate any help.

Thanks!

Mitch

Never mind - with a little more searching, I found the solution:

``````function PredictGroundHit()
{
var h : float = ground.position.y - (transform.position.y + collider.radius);
var g : float = Physics.gravity.magnitude;
var vyi : float = rigidbody.velocity.y;

var t : float = vyi/g + Mathf.Sqrt(vyi*vyi/(g*g) - 2*h/g);

var x : float = transform.position.x + rigidbody.velocity.x*t;
var z : float = transform.position.z + rigidbody.velocity.z*t;

groundHit = Vector3(x, ground.position.y, z);
}
``````
1 Like