This is kinda hard to explain why i need it but is there any way to make Ai character move back to nearest location of the navigation mesh? for exemple imagine there is a planar non nav mesh area (restricted with nav modifiers) in the map and I throw the ai character to that area and it stops moving because it doesnt have navigation area, is there any way to force the ai to move to a near navigable area so it can keep with is life?
The problem is that the nav mesh is by definition the area where the AI knows how to navigate the character, and when outside the mesh, the AI doesn’t know how to navigate.
You will have to figure out what behavior you want to move the character back to the point.
You can use a function to get the nearest point on a navmesh to some other point, but there’s no guarantee that this point isn’t blocked by a wall or something similar.
So – you could get the nearest point on the navmesh, and then lerp the position of the thrown character to that point over some amount of time, and that would put the character back on the navmesh, but it won’t interact well with arbitrary geometry.
Hi there, there are special actors called navlinks that serve to connect two navmesh volumes. These actors are also used if you want AI to jump between platforms. But, as stated before, your code should search for a reachable/navigable location before spawning the AI actor in the first place. There are nodes that handle such queries and return a feasible location.
what nodes can i use to get that nearest location point on nav mesh?
Hi, I didnt want it to spawn was more like move it from a “forbidden” zone, for example, my floor is always plane but are some areas that have a nav modifier so the npc doesnt go there but sometimes gets thrown in there and cant leave, i just really need it to walk to the nearest location on nav mesh, do you know any nodes that gives me that or something similar?
You can’t use the AI movement nodes because they need the navigation mesh.
You’ll want to make a node that manually turns the character towards the target point, and manually emits the “Add Movement Input” call to the character each tick.
This is really no different from the input handling code in the player pawn – “if I want to move forward, add movement input with X=1”
i did that manage to get back to the nav mesh but it seems that the " add movement input with X=1” keeps going for ever making the character move in a straight line bumping to walls and not rotating like its should, how to i fix this? I tried to put x=0 after a delay of 2 seconds and nothing
I figure ity it was a nav modifier inside a blue print that was causing this glitch, the said nav modifier is turning the nav mesh red in a huge area:
this is the nav modifier inside the door blue print:
i cant change the size or anything to make that area smaller, how can i fix this?
If you can make a code that detects whenever the AI reaches a forbidden area, then you have a solution. Either throughout overlaps or phyical materials in the floor. I am not sure if is possible to detect the presence of a navmesh modifier, unless you add box collisions to that. So everytime the AI passes through it, you can trigger “on begin overlapping” events.
That area in red wasnt suppose to be that big and it exists because the area class of nav modifier on the door bp is set to “obstacle” do you know how to make it smaller?
I am quite sure you may be able to reduce the scale of the navmesh modifier box. Select the modifier and take a look at details panel. Look for scale xyz or box dimensions. I am out of town without my computer, I am unable to review this information.
It seems there is no option to resize it, because it is an actor component, not a primitive component.
I would try differently. Remove the navmodifier and add a cube static mesh. Resize it to your needs and add a code that change its collision settings as follows:
Door: locked - set cube collision as “block pawn” and “can ever affect navigation” to true.
Door: unlocked - set cube collision to ignore all and set “can ever affect navigation” to false.
So how do I add a primitive component to the bluprint? also is there any way to edit area classes?
A static mesh is a primitive. Click on the green button “+ add component”. See my previous post.
The Problem is that i cant acess the “can ever affect navigation” via nodes in bp, i found a solution that was: creating a separate blue blueprint with only a nav modifier (if there is only the nav modifier i can select the affected area in the Failsafe Extente parameter, dont know why tho) and set this nodes inside of this blueprint:
If the area class of the nav modifier is set to “obstacle” the AI seems to avoid it while it can walk on it.
Then i placed thos nav mod BP in the places i want the AI to avoid if it gets sent there
Sounds good.
Use Project Point To Navigation, or you can probably use an EQS query (i don’t have much experience with those yet). ProjectPointToNavigation | Unreal Engine Documentation
If your characters are NavMeshWalking, they should switch to Walking automatically once they are off the mesh.
Once you find a point, do a MoveToLocation() with pathfinding turned off, and it should get you there. If it does not, you could either lerp to it, or just teleport to it.
Then if you’re using NavMeshwalking, make sure you switch that back on once they are back on the mesh.