Hi, I have a projectile and a target.
Both objects have: Vector2D velocity and Vector2D position. How do I find the predicted position just using the target's position and velocity, together with the projectile speed?
If you want a predicted position for moving things then you must have some kind of clock, because the predicted position will change over time.
If the velocity of the target changes then it becomes harder. Is the change predictable (eg following a trajectory under gravity) or does it change unpredictably (eg performing avoidance tactics)?
In that (simple) case you have two equations for the position at time t Pt, given the initial position p and the velocity
pt1 = p1 + v1.t
pt2 = p2 + v2.t
Ifthe two obects are going to collide then their positions must be the same at the same time, ie
pt1 = pt2 = p1 + v1.t = p2 + v2.t
now you can just solve those simultaneous equations to find the point of collision (pt1 or pt2) and the time at which they collide (t).
If there is no solution then it means the two objects will pass by without colliding.
Hi, sorry it took me too long to get back to the problem....
I get what you're saying.. but I have to use time = distance / velocity.
So, Distance1 / Velocity1 = Distance2 / Velocity2
then sqrt((x - x1)^2 + (y - y1)^2) / Velocity1 = sqrt((x - x2)^2 + (y - y2)^2) / Velocity1
I just have to find (x, y).