How to make a flying AI character drop bombs on a moving target

Hello all!

I’m working on a 2D side-scroller type game for mobile. At this moment, I have a flying enemy character with a droppable bomb-type actor attached. My goal is to set up a targeting system so that my enemy character will drop the bomb so that if the player character is either standing still or maintains its movement at the current speed/direction, the bomb will pretty much bullseye the player character (small margin of error is the goal, but some slop is fine for playability reasons).

I haven’t yet started scripting the release timing, but my current idea revolves around using 2 box collision components attached to the flying character to act as triggers, whose position forward of the flying character is scaled by the forward velocity of the parent flying character. The further trigger would either trigger a drop event right away or a delay (depending on player character direction, speed, is moving status) and the second would be essentially the same. I can’t help but feel like there’s a much nicer/cleaner way to implement this kind of targeting, but I’m still learning and haven’t been able to find tutorials for this sort of thing.

Also, my bomb is a simple physics object that upon release has physics simulation, gravity, and collision enabled and is then given a small impulse based on the dropping character’s forward velocity. It has no movement component of its own, as it’s intended to be just a falling object.

Thoughts, anyone? Am I on the right track here?

I started a thread on the forum shortly after posting here and I seem to have reached a viable solution. Here’s the forum thread link for reference:

As for details, I located a small library of physics equations that included information on ballistics/trajectories. In there, I found a calculation for the range of a horizontally launched object. I simply created a custom function to crunch the numbers and generate a range for my bomb. When added to the current location of the bomb dropping enemy, this provides a target point that loosely predicts the location at which the bomb will land.

There’s fine tuning to be done with this method, but thus far it seems to be a fairly simple way to make sure that the bombers are fairly accurate (with a couple of caveats in my case, I still need to add logic for certain scenarios).

In case it helps, here’s what the custom function looks like in BP form:

It’s worth noting that UE4 physics align closely with real world physics, so if you can’t get a GravityZ reference and there’s no unique gravity settings in the objects you’re calculating for, 980 is the base value to put in the GravityZ input (I know the engine represents it as -980, but the negative throws the calculation).

I hope this helps anyone looking for some bomber logic!