How to get following enemy to fly?

Hello, I am trying to create an enemy that will follow the player. The player in my game is able to fly so I would also like the enemy to be able to fly (move up and down) in order to reach the player. I followed this very short tutorial to figure out how to get an enemy character following the player: Unreal engine 4 tutorial: follow the player - YouTube

This enemy character appears to only navigate when placed above geometry. I tried enabling “can fly” and disabling all gravity options but it didn’t appear to enable the enemy character to fly.

Does anyone know of a way to solve this problem? Does it perhaps have something to do with the navigation mesh?

Thank you.

UE4 doesnt have built in flight navigation as far as ive seen. there is however plugins for flight nav like DoN’s 3D Pathfinding for Flying AI. ive never personally used it but seems like the type of thing your looking to do.

If the area you’re flying around in is very simple, without airborne obstacles that the AI needs to fly around, then you could probably get away with just aiming your flying AI enemy directly toward the player’s 3D location.

In other words, you could make a vector that points from the AI enemy toward the player, normalize that vector, and then use this vector to add movement impulse to your AI enemy. In this way, the AI would always fly directly toward the player’s current location.

Admittedly, this would create very primitive behavior, but it could be improved further by adding some prediction math so the AI enemy tries to intercept the player instead of always following behind. Up to you which would work better.

^ agree with The Batch… and to make it able to avoid obstacles (without using a navmesh at all) you could use traces to check for obstacles in front of your flying AI…

Good idea, @aNorthStar. If the trace detects an obstacle, you could make the AI enemy always “veer right” or something. That should work.

@the_batch… yes, and if you’d like to get advanced…

  • use line traces angled (say) 30 degrees up down, left and right of
    your character as “whiskers”… rotate your AI away from the collsions
  • or a capsule trace and use the collision location
  • or some combination of both

Initially you could set it up on Tick, but… to save your performance… you could fire the traces on a timer.

This setup would need some tuning but is achievable imho.

Now we’re talking! (And quite possibly reinventing the plugin that was linked earlier!)

Fun ideas. :slight_smile:

ah yes… Rama’s plugin is very interesting… I have played with it for a couple of hours.

I know FOR SURE he uses a voxel system (which is completely different to my approach, kind of a 3d navmesh) but I THINK he might offer a second ‘light’ option… which uses traces similarly to my suggestions

Actually, for my own project, I’ll be needing flying AI at some point in the future. Maybe in 3 months… I’m really looking forward to developing it :slight_smile: