How would i design a flying enemy AI?

Currently im looking to add some variety to my game, by adding a flying enemy of sorts.
Im not looking for a flying pathfinding so to say, im just having troubles wrapping my head around designing the AI itself, the movement specificially.

If you have ever played risk of rain 2, im basically trying to create a lesser wisp, that has a similiar behaviour.

For any folks that havent played risk of rain 2 i’ll link a video where you can see how they behave

I have already tried making several flying enemies, but most of them didnt work correctly, or were just static and not fun to fight against.
I want the enemy not to ram the player, but try to keep their distance, and float in the air, sometimes getting closer or farther, or circling the player.

This should help:

Please search the forums for your question before making a post. I guess this is also a unique case though as you are trying to recreate the wisp thing.

Regarding the flying stuff, I have linked the thing above and have also given my own info below. (click the button arrow thing.)

Do you have other questions regarding making the wisp?


my own random knowledge that may or may not be helpful

General list of things you need to do for any custom character enemy:

  • Design enemy - find what you want to make
  • Model enemy - inside something like Blender
  • Rig enemy - (this can be done inside something like Blender or could be done inside Roblox. I personally use this: RigEdit - Create and edit animation rigs!)
  • Import into Roblox Studio if you haven’t yet.
  • Roblox specific additions
    • After making sure that everything in under a ‘model’/‘group’, you can use Roblox’s “Humanoid” component to make many things easier. Or, you could code all that yourself.
    • A ‘part’ under the ‘model’/‘group’ named “HumanoidRootPart”. Make sure this is facing the way you want it to. You can test the ‘front face’ by using a decal.
  • Scripting/Programming - you can make your own Animate script that handles things like walk animations, user input, client stuff for attacks (use ‘Remote Events’ to connect client and server), etc.
  • If this is an enemy, then you should probably have a hitbox. This is usually a square/rectange based on the side of the custom character that you have made. Make sure this ‘hitbox’ part isn’t anchored (unless you go for that), and that the ‘hitbox’ part is welded to something (best to weld to HumanoidRootPart as that should be the middle of the character usually.)

I know of three ways to make a flying enemy specifically:

  • Anchor the HumanoidRootPart and move the custom character around using TweenService. With this, it will be harder to do certain things. Linear motion, motion on a single plane such as x, y, or z, will be what this option does best. You can also do diagonal movement with tweens, but in will use a A to B method if that makes sense. You can tween a ton of things easy with this like the ‘Enum.EasingStyle’.
  • Constantly change the humanoid property, hipheight. The higher number you go, the higher your enemy should be compared to the ground. You could lerp, or tween, or whatever method to go from one hipheight to another smoothly.
  • body movers. I don’t have much experience with these.

I didn’t really have any other question other than the movement itself, i’ll try using bodymovers, since they look the closest to the movements im trying to replicate.

1 Like