I'm trying to find a good solution for a bullet to hit the enemy. The game is 2D tower defense, the tower is supposed to shoot a bullet and hit the enemy guaranteed.
I tried this solution - http://blog.wolfire.com/2009/07/linear-algebra-for-game-developers-part-1/
The link mentioned to subtract the bullet's origin and the enemy as well (vector subtraction). I tried that but a bullet just follows around the enemy.
float diffX = enemy.position.x - position.x; float diffY = enemy.position.y - position.y; velocity.x = diffX; velocity.y = diffY; position.add(velocity.x * deltaTime, velocity.y * deltaTime);
I'm familiar with vectors but not sure what steps (vector math operations) to be done to get this solution working.