Monday, September 14, 2015

algorithm - Predicting enemy position in order to have an object lead its target


In my 2D game I have AI turrets that should assist the player by automatically firing towards enemies. I would like to make them fire intelligently and lead their target instead of just targeting an enemy's current position. So, given the (always constant) velocity and position vector of both the enemy and the turret's projectile, how can I find a vector that represents the actual position the turret must target in order for the projectile to intersect (and hit) the enemy?



Any links to articles that describe the math, algorithms, etc. would be appreciated!



Answer



This question on GameDev, and this question on StackOverflow should provide you with the answer you're looking for. :)


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...