Bullet and hitting moving target - best practice?

Hi All,

I am creating a game that player place tower to defend a horde of enemies (refuse to use the Tower-Defend keyword, because it really is not).

When thinking about the bullet, there are several approach and I wonder which one is the most suitable
Generally, we know that (static) tower fire a bullet to hit a (moving) target.

A) Aim dumbly + actual bullet physics - Tower aim at the target position at time t=0 and fire the bullet.

Depending on the flight time of the bullet, and the speed of the target, the bullet could miss the moving target. By the time it reach that position, the target has moved

B) Aim with lead + actual bullet physics - Same as A, but the AI try to ā€˜guess’ the future location of the target

If like simple TD genre, the target mostly move in linear fashion, so this could works. What if the target movement is more advance (accelerating, jumping around).

C) Homing bullet ! - Bullet that somehow ā€œhomeā€ on the target, hence not moving in straight line

This might look really silly

D) Mark of death - Once the bullet fly for some distance or reach close enough to the target. The target dies regardless of whether the bullet touch it or not

This might also look silly.

I think of course if we set the bullet speed to be very very high, all above is irrelevant. What are the best practice out there?

Appreciate your feedback !

I would suggest using B. It will work for any case that doesn’t involve actual random movement. You have a choice you can either make it so a tower picks a target and no matter what his bullet will damage that target (This is how most tower games work). You can have it so your tower picks a location and if the bullet ever collides with a target it hits it. (maybe if the user takes over the tower).

But generally if your going to have it so option A (tower always hits) your most likely not going to have random movement. Even if your guys accelerate and jump around to make them seem harder to hit, you still have whatever algorithm your using to do this, so you can easily predict where they will be at Time T. Now if you do have some kind of random factor to their movement, you can always implement some sort of ā€œI’ve been targetted stateā€ where their movement stops being so random and erratic and converts to someting you can predict. The User won’t notice, since the bullet time will be pretty quick.

1 Like

Generally speaking from my experience most tower defence style games (I know you dont consider yours a td, but obviously this issue is tackled in them) use the homing bullet approach + fast projectiles. This works fine most of the time, but if a targets far away it can look silly. Personally I would go for the ai working out where the target will be in the future, if your using its current velocity to predict the shot you could easily miss, so the best option would be to use the path they are following. If you know the way they will go you can do some line math to work out at what point the projectile will need to aim at to get a hit. If you also allow the projectile to adjust its course if the ai has a significant change in velocity it should hit the majority of the time.

Alternatively you could just cause damage to the target and have vfx to show the turret fired and the target got hit, but this can end up looking pretty naff.