For my map, it's very curvy and the node sizes aren't consistent. I have everything finished so that projectiles will actually fly at an enemy, however if a projectile is going too slow it will miss. I am wondering if I should just go the easy route, and just make the projectile homing, or if I could get help here on where to start. The enemy is changing directions, and moving around, although never changes speed.
I'm unsure if this is for the purposes of the look of the game, or if it's for balance.
If it's for balance, I think projectile speed is totally fair as an attribute the user will have to consider. In this case, just don't worry about it and perform "real" hit detection. Some users (like myself) like this.
If it's for looks and you don't want speed to be part of the balance, I think you could "predict" where something will be (after you've chosen your target so you don't waste tons of calculation time on objects you're not firing at) by (without displaying it) having the move function occur several times and the firing angle/time-to-target occur several times, then pick which one is a hit, then let the game use those values.
This would look something like: `
Target = someCreatureObject OldPosition = Target.Position for (i=0; i<5; i++) Target.Move() if(Tower.FramesToTarget() == i) PositionToAimAt = Target.Position break Target.Position = OldPosition return PositionToAimAt
` Where FramesToTarget would be some calculation of the speed vs. the distance. A note: you'll have to give yourself a way to know if none of the positions it could shoot would hit and then decide what to do from there.
- Increase projectile speed and use the Quadratic Equation like the answer found here: How do I fire a projectile at where an object will be located in the future?
This would make the coding a tiny bit easier, but I don't think the function I posted would be too hard.
I'll mention that one of the original Tower Defense games (my favorite of them) Flash Element TD had a mix of projectile speeds and I believe used homing (you can tell if you use the cannons.) This homing was virtually un-noticable.
NOTE: in all of the above cases, Area of Effect weapons should use real hit detection for the AOE damage after decided where the hit occurs.
Even if you could predict the enemy's movement, you mentioned they might change direction, so that would either not work or be too complicated.
My favourite way is to make the missile homing. Keep the enemy's position in the missile's code as target (careful, don't keep a copy of it, keep a reference of it, so you get enemy's new position). Every frame approach target in a linear fashion, depending on missile's speed. This could go wrong if you had a missile that has a speed lower than the enemy's speed.
A lot of games have done this in the past, including warcraft 3, and if I'm not wrong, dota2 still does this. It's the safest way to guarantee that once you fire a missile, you will eventually damage the enemy.