Flying AI doesn't work in the air

Hello dear friends

I want my flying AI to just fly towards me as soon as it sees me. I have a blueprint for it, but that’s only for units that are on the ground. At least I’m assuming because it doesn’t work with the flying unit. I have no idea how I can attach navamesh to the air, can someone help me with this, thank you very much

I post all information + video


Screenshot 2024-01-04 204418


Navmeshes are 2D (X,Y)

Check these out:

1 Like

Thanks i will go for it

The cool thing with flying is that you don’t need navmeshes, because you can just fly straight wherever you want to go.
So, when flying, make your AI controller simply issue a vector/velocity/movement in the direction of the player (or wherever it wants to go.)

If you want to “fly in the air” but follow the navigable space of the navmesh, then you should model your asset to have a standard ground collision, but offset the mesh however far up into the air that you want it to hover. E g, it’ll still “walk,” it’ll just render as if it were flying.

1 Like

The “ground in sky” is super clever.

But I suggested those (free) assets because if there are obstacles (especially if they are dynamic), then real-time pathfinding is required.

1 Like

Hello friends
I’m really at my wits’ end when it comes to a flying opponent

So now I’m just trying to program a projectile movement so that it moves in the air in my direction.
My question is, is it possible to tune a projectile to move as soon as it sees me, i.e. with Pawn Sensing?
i upload my Bp image
Because the problem is now taht it moves in my direction but not if he sees so at the begin of the game he starts to move

(I know that’s not the right way for a flying opponent, but I’m still far too new to unreal to be able to do everything without being able to see the whole thing in a video or picture)

I don’t understand.

Are you saying that the projectile moves WITHOUT seeing the player first? That you want it to wait and THEN when it sees the player, to start moving?

Yes i want that he starts moving when he faces the player :slight_smile:

Then you need to set the condition for that.

There needs to be a loop function (or event dispatch, etc.) that is testing for that condition.

Basically you need to have a function that keeps asking “Is the player looking now?”, and when the player fulfills those requirements to make the statement TRUE, then you would execute the AI movement.

You can look up tutorials on event dispatchers, or create your own loop function.

Thank you very much for the quick answer but is the whole thing also possible with a bp actor tyb class that uses the projectile movement?

Maybe?

You have to understand how the tools you’re using behave, and I have no idea what you specifically trying to do.

Projectile movement is just an impulse algorithm, but it may break if you try to use it for anything else than shooting something like an arrow or bullet.

If I were you, I would experiment with these things first.

1 Like

I actually just want the AI ​​in my side scroller game to start running towards me as soon as it sees me and I can do that perfectly on the floor with the BP that I posted at the very beginning, but as I said, it just doesn’t work in that air

ME—><—Ai afters sees me

What I missed was making my AI from the tutorial:

What he taught me works, but I want the AI ​​to move after it sees me

I’m giving up on it now because I’ve been stuck on it for 4 days. I’ve just placed boxes in the air that don’t move but can be destroyed by my character’s attacks

But thank you very much for your nice tips and try to show me a way
i go for it in the future :smiley:

now I just used what I can to finish the side scroller…

1 Like

Ah, okay, it’s making more sense now.

The issue could be that you need to learn how the FLYING Pathfinding works.

I actually don’t understand how it works because I’ve never used it.

1 Like

Yes i go to work on it :smiley: and learn learn learn…

Also, maybe try this:

Add: GET_DISTANCE_TO, so, the enemy doesn’t go after your player right away:

OK, cool, thanks, I’ll try that right away

Hmm nothing happends it stay still in the air… :confused:

No, I meant you need to ADD that to your code.

It was just an example.

So you have:

-ON_PAWN_SENSING → CAST → (MOVEMENT DATA) → BRANCH → MOVE_COMPONENT_TO

What I want you to do is:

-ON_PAWN_SENSING → CAST → (Place blue cast pin into “Other Actor” of GET_DISTANCE_TO) → GET_DISTANCE_TO → (Place green output pin to LESS_EQUAL, putting whatever value you want) → (Attach red output node to BRANCH) → (Connect the rest of your MOVEMENT DATA) → BRANCH → MOVE_COMPONENT_TO.

ok sorry haha im to noobie

I tried it a bit with my BP, but well, I’ll go the exact route you describe

1 Like

Oh! Make sure that the first branch condition is TRUE, otherwise the enemy will ALWAYS or NEVER move.