I'm creating a game in a grid (like Chess, x/y coordinates) on this game there is some projectiles which have to hit moving targets.
Moving targets follow a path (get with an A* pathfinding) composed by X steps of X/Y coordinates. Projectile don't follow a path, they are going straight from the sender to the target.
I would like to calculate the coordinates where the projectile will hit the target (according to his path)
I tried to use: 2d game : fire at a moving target by predicting intersection of projectile and unit but this algorithm does not work if the target turn during the projectile fly.
Can you help me with this algorithm?
As input I have:
- Cordinates of each step of the target path
- Velocity of target & projectile
- Actual x/y target position (It can be a float like x:7.61, y:5.22 if needed)
- Position of projectile sender
You can consider that:
- The target never change his path during a projectile fly
- If the target is not moving, the velocity is equal to 0
- The projectile start can be delayed if needed
Thanks for any help!