How to make flying enemies follow the player?

Hey peoples.

I bought the A* Pathfinding and it works very good so far.
At the moment i tried from the documentation to let the enemy find the player or go to a special position.
He also can climb up (for ground enemies), is very good.

The game i wanted to develop should also have some flying enemies. They also should try to follow the player.
Is there any way to do that? At the moment it feels the AI always have some kind of gravity, even without rigidbody or something like that.

So is there a possibility to let flying enemies search and follow the player? :slight_smile:
Thank you

Hi

I’m glad you like the package :slight_smile:
Do you mean enemies that fly in all 3D directions or enemies that are just like normal ones except they hover a small distance above the ground?

The enemies should be possible to fly also over the edges of the ground.
So if the player is maybe on a platform and flying enemies are coming from outside (over the edge) to attack him.
If the attack is coming, as example diagonal (from a top side higher than the players Y value) to the player and the player avoid the attack, the enemy had first a positive Y value, then because getting slower and turn back in some way from the negative Y position. (You know because they dont stop directly, they fly some curve).

My explanation in english is a bit strange if i read my own text. :smiley:
I hope you can still understand. :smiley:

Edit:
I read your question again, is more simple to answer that this way.
Yes some enemies who can move in all directions (imagine you are in space or just flying enemies).

Ok.
That is very tricky. Or rather, real 3D pathfinding uses a huge amount of memory and is very slow (I have implemented it before).
Is your world perhaps a 2.5D world of some kind? I.e there is only a single layer, no overlapping geometry like bridges over other walkable surfaces?

Yes its a kind of 3D platformer with shooter elements in it.
So sometimes ground enemies are possible, otherwise flying enemies and traps.
Because of this i have many different heights.
Is there some kind of 3D pathfinding beta that i can test to see how much it will slow down the game?

Could you post a screenshot perhaps?
What graph type are you using for your ground enemies?

For flying enemies actually i dont have any grid because i dont know what to do.
The ground enemies using layerd grid or the normal grid if they dont need to go upstairs.
Its not fully implemented in all of my levels.
So just trying all kinds i can do with that.
(Its my first day with the AI).

What would you recommend me to make enemies fly, you know there are some games also can do this.
Do you have an idea how they make this possible? Or is there some option i can use to try it with the actual script?

Edit:
For the flying boss i want to implement, i think i can use waypoints in the boss room to let him do stuff.
But for the normal flying enemies they will do melee attacks.

Do you think you could post a screenshot? It’s easier to understand the specifics then.

I asked for this, but i cant show any screenshots of the game at the moment.
The peoples i am working together with dont agree sorry.

But you know what i mean with the flying enemies?
Lets say you have a bee attacking the player.
Some behavior like this would be great.

When people say flying enemies they mean widely different things.
Do you have a video or screenshot of another game with a similar mechanic to the one you are trying to achieve?

I think at the moment also a simple solution would work.
For the future it could become a bit more smooth and better.
So any simple solution for the moment would do it, because we dont need to change the game because of missing flying enemies.

Something like this in minute 6:12

A random flying movement in direction to the player would look nice. (unsure movement like a fly or a bee).
And an idea would be, if the enemy attacked the player, it flee for a short time in a random direction away from the player and then attacking again in a relative random movement in direction to the player.

The simple solution would be, the flying enemy take the direct way to the player, stay in front of the player and just attack him. (Which would also be good for the moment).

Maybe you like develop this in future updates if this is actually not possible(?)
I think this AI have so much potential i would very appreciate if this will be the ultimate AI solution.
At the moment it still solves a lot of problems and makes it a very fast and smart solution for any kind of ground enemies or for fleeing animals and so on.
When i told the peoples which develop together with me, that your AI worked, all cheer about that situation.
They all know how important a good AI is. :smiley:

Hi

For that kind of behavior I think it is a much better idea to go with some kind of steering behavior instead.
Pathfinding will not be of much use because most of the time it will just say “there is a straight path to the target”. Possibly one could augment it with a very low resolution point graph (one node every 10-50 meters or something) to be able to find paths around buildings. I have had some success in another game with implementing this by checking several different potential future paths and using raycasts to figure out which of them was the best one.

Hey!
That sounds complicated, you have a sample scene or sample project which i can download?

Sorry. Those kinds of behaviors are not in the scope of this package, I do not have anything like that implemented at the moment.

Ok, thank you very fast answer. :smiley:

Bump for a question
If I wanted simply a hovering enemy how would I go about this?
I created a second (grid) graph and set the gridmask to that grid for the hovering enemies but can’t seem to figure out how to get the enemy moving on this with either the charactercontroller or the ROV controller
When using the charactercontroller I can’t seem to get gravity disabled
When using ROV I can’t get any movement at all when the AI is placed floating in the air

I second this, my original goal was to have floating enemies in full 3d space without needing a platform underneath as well. However, Aron explained the limitations as he did here and I accepted.

I shall now compromise and try hovering enemies above a platform. I just assumed I would have the root object at ground level and the actual model as a child object and just put it at a higher Y position. However, there is probably more to it so Ill just wait and see :slight_smile:

Oh, just realized those hovering units would need to go over walls and obstacles that ground units could not pass through. I’m sure there are tags and settings and what not that one can assign to the hovering AI to allow it to go over said obstacles. Feel free to mention a few in the reply :slight_smile: (I’m still getting started in documentation so I apologize if it’s already in there)

A hovering unit is exactly the same as a grounded unit. Just move the rendered mesh some distance upwards (not the root game object, only the rendered mesh). It should still use gravity, but since the rendered mesh is moved upwards, it doesn’t look like it is touching the ground.

Could you have 2 graphs, one for ground units and one for hovering units?