I'm making a tower defense game where the towers are shooting projectiles at enemies. I do not want to make the projectiles homing, and I want to make sure that when a tower fires a projectile, it will hit where the enemy is going to be, instead of firing at where the enemy is currently located.
My givens are the position and velocity of the enemy, the position of the tower and the speed at which projectiles travel. There is no acceleration.
I was considering taking the distance between the tower and the enemy, calculating how long it would take the projectile to connect with the enemy, and then using that to calculate the future position of the enemy, firing at that instead. However, now the distance between my tower and the enemy in the future might be different, so my calculation isn't going to be precise, and it might miss.
How do I correctly calculate where to fire the projectile so that it will always connect with the moving enemy?