AI does not walk off ledges

I try my first steps with creating some basic AI in a third person template (copy of the third person character with removed camera and empty event graph). It works (AI is followimg my player character) if I trigger it via the level blueprint… but the AI controlled character seems to be scared to jump off ledges. I I jump from one of the meshes in the third person example he turns around and takes the stairs instead of jumping either. I saw a tutorial (with an older engine version) where this worked: Unreal Engine 4 Tutorial - Basic AI Navigation - YouTube. My NavMeshBoundsVolume covers the hole third person map (everything greenish) as in screenshot below. Was there some changes in later versions of the engine so the default behaviour changed?

234abae62242cedb0e1b604f70ea18ebb809b503.jpeg

1 Like

Did you try to use Nav Link Proxy? The example content does contain an example to this :slight_smile:

Nav Link Proxy makes him jump. Thanks! But he is only jumping at the nav link proxy (no where else) and this still differs a lot from the behaviour as shown in this tutorial of an older engine version: https://www.youtube.com/watch?v=-KDazrBx6IY
Actually the Nav Link Proxy seems to work like an insvisible bridge and this would protect him from being a lemming if I jump into death but would make him look dumb if he should catch me in a straight line but instead of following me at the shortest path he have to take the long way to some Nav Link Proxy first (even if the depth of the jump is everywhere the same height).

Maybe the AI needs a behaviour that if anything obstructs the direct path (like a ledge or a drop??) it can try and do a jump towards the player? Surly that would make it “jump off” the ledge unintentionally, but still do what you want it to.

Yeah the default on the AI is to not jump off ledges over a certain height. You should be able to tweak that in the nav settings to increase the height that they will jump from.

Sounds good. Any idea where I could find it?

Actually it seems the “can walk off ledges” function doesn’t work so well at the moment. Check out Rama’s work Rama Available, Counseling, Steam/Multiplayer Code, UI, C++ Game Mechanics - Looking For Work? - Unreal Engine Forums

Just use a “Nav Link Proxy” - Content Examples Sample Project for Unreal Engine | Unreal Engine 5.3 Documentation

Nav link proxy’s only work in 1 location, not along an entire ledge

Oh yeah … LOL … put a box trigger on the ledge … when bot enters … disable navigation and make them run straight off the ledge.

Sounds like a non-dynamic leveldesigner workaround for a feature that seemed to work already in previous versions of the engine and a bit less like AI. But thanks for the hint.

Yeah that doesn’t quite solve the problem. I think you will need to modify the navmesh to understand a maximum height that the character can jump from safely or do like Rama did with his.

You could go the oldschool way about and line trace the jump distance in front of the character downwards to see if he can clear the ledge. Or if the floor is low enough he won’t suffer damage jumping.

Then you can drive the AI decision from the result of the hit trace.
if you set the distance of the line trace properly you can go back to default when no result is found. If instead you have a hit you can force the AI to jump and return to the regular states.

If you do that,
You are probably best off solving where to start the line trace by solving a parabola formula that takes in velocity of the actor and current x/y world data.
You can find info on what I mean and formulas on here Projectile motion - Wikipedia
You will need to solve for a Z. I reccomend just taking in the Z of the pelvis bone as the final point of the parabula to start the downward trace. Just so you are sure that the jumps can be cleared.

ofcourse you could bypass any math and just trace 1.5 m in front of the character starting at the hip downwards by a maximum of 2m and upwards by the scaled character capsule (which should be the distance from hip to head since its halved by default).

It’s a bit complicated, and hooking it up to the AI is no picknick, but if you are looking for a real solution that doesn’t involve editing the level or the navmesh this is the most likely way to go about it.

So I think I solved the problem. In the Ai character blueprint viewport you can go the movement block in the hierarchy and then search ledge. You will find max distance it will jump off. In the scene you can find recastnavmesh and search for agent. turn agent radius down and turn the max vertical jump height up. hopefully this helps! (I know I wrote it like a 5 year old its almost 12am for me).

1 Like