Bullet trajectory to hit enemy along spline moving at a constant speed

I am making a Tower Defense game in which the player places down defenders that shoot at enemies. These enemies move at a constant 550 cm/s along a spline. How am I supposed to fire the bullets at the enemies? Right now, I am using the Look At rotation, but since the enemies are moving, it will always fire the bullets behind the enemy. Since the user can place these defenders anywhere, the trajectory calculation needs to incorporate that distance too. How should I get started with this problem? Preferably using Blueprints, but C++ is fine if it is much harder to use Blueprints. Thanks!

Once you have the needed sides of the triangle (through subtracting vectors and getting the resulting length) you can get the angle through basic trigonometry

If I find the time I’ll do a c++ implementation.

Edit: You’d need to add in the time needed for the projectile to travel the set distance based on it’s speed.

1 Like

Thanks for the answer; however, how should one obtain the time? Velocity * time equals distance, but since you don’t know the point until you solve this equation, it seems impossible. Also, how would you factor in the bullet speed?

What I have right now:


where the 0.3 is where time should be.
Thanks!