Confuse about Vector and AddForce to reach target

I’m trying to make an object reach another. (Yeah this sound like something I could find in google first, I found many utils link but not what I wanted).
My object is in the floor and the target is flying,
The object is a rigidBody with gravity, and I want to set a velocity or call to AddForce, but I want to call addForce just one time, I’m using ForceMode.VelocityChange.

To get the vector destination I’m doing this:

 Vector3 destination = targetPosition - playerPosition;

If I play with destination, multiplying by random number like 50, it’s work . (Of course more fast than I want)
I was trying to find tutorial’s on internet to understand the formulas for this, but I couldn’t .

Maybe because there is the gravity of unity, I’m getting confuse with the formulas I found on internet, or maybe is just me that I don’t understand.

So how can I calculate the vector that I need to reach the target, ?
Someone can help me :slight_smile: , sorry for the newbie question.


if you are here, after long time trying to find something similar like me, here is the code:

Vector3 direction = new Vector3(hit.point.x, hit.point.y, 0f) - actualPosition;
float tan = (direction.y * 4 / (direction.x * 2));
float dg = Mathf.Atan(tan);

float velocity = Mathf.Sqrt(((direction.x * 2) * 9.81f) / (Mathf.Cos(dg) * Mathf.Sin(dg) * 2));
Vector3 v = new Vector3(Mathf.Cos(dg), Mathf.Sin(dg), 0f);
GetComponent<Rigidbody>().AddForce(velocity * v, ForceMode.VelocityChange);

you gotta aim where it’s going to be, not where it is :wink:

To truly solve it you’re gonna need to use ballistic calculations, if you’re into that stuff and know a thing or two you most of the equations you need are here: Projectile motion - Wikipedia
if you need some hand holding this one is nice : https://www.youtube.com/playlist?list=PLFt_AvWsXl0eMryeweK7gc9T04lJCIg_W

but if you just want to get something going like a tracking missile, a thing i always try out is aiming at (target.position + target.velocity), it works wonders a surprising amount of times.

Thanks I already did something with this, that video save me hahaha