x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

AI walks outside of NavMesh

I move the AI using MoveTo (inside a behavior tree) and then assign the TargetLocation as the player location. The player then walks to the end of the ledge shown in the screenshot below. The AI sadly follows the player outside of the navmesh. And then the AI get's stuck because, there is no navmesh where he is standing... But the AI should not ever get outside of the navmesh...

How can I prevent the AI from walking outside of the NavMesh without resorting to 'spamming' invisible walls?

alt text alt text

Product Version: UE 4.11
Tags:
bp.png (577.6 kB)
bp4.png (12.1 kB)
more ▼

asked Apr 29 '16 at 08:45 PM in Using UE4

avatar image

Napoleonite
595 90 104 155

avatar image Napoleonite Apr 30 '16 at 08:53 AM

Could it be an UE4-bug? Reproduced in other projects as well. Also applies to both SP and MP of course.

avatar image v.s. Apr 30 '16 at 08:17 PM

If movement mode is Walking then character can move anywhere outside navmesh. If movement mode is NavWalking then character can move only on the navmesh but can trigger navmode to Walking if it is outside navmesh.

avatar image Napoleonite May 01 '16 at 08:26 AM

That sadly didn't change anything. The AI still walks outside of it. If the player jumps outside of the navmesh at the same time the AI does it's moveto-player in the behavior-tree then he will walk outside of the navmesh even with that option enabled in it's character-controller. And then when it arrives at it's location outside of the navmesh it will be stuck.

avatar image v.s. May 02 '16 at 09:16 PM

In Walking mode a character should not stuck anywhere. What a gameplay debugger output for moving and navmesh in runtime?

avatar image Napoleonite May 03 '16 at 07:42 AM

I'm not sure what you mean, all I know is the vislog: alt text alt text

There is a weird cone visible at the end when the ai get's stuck. The vislog stops at that point. alt text

vislog.png (10.1 kB)
bp.png (23.0 kB)
bp2.png (118.3 kB)
avatar image Napoleonite May 03 '16 at 07:46 AM

And the editor seems to crash so now and then when using vislog...

I did find out that the NavMeshWalking DOES restrict enemies from moving to a location outside of the navmesh (when making them walk to a VECTOR-location). But when using MoveToTarget (player) they do not and they will walk outside of the navmesh and get perma-stuck. Is this a bug?

Even when the targetlocation and lastknownplayerlocation are the same, one node works (restricts to navmesh) but the other one does not. Note that TargetPlayer is typeof playercharacter and lastknownplayerlocation is a vector.

alt text

Also the vislog shows a red bar when navigating with lastknownplayerlocation when the lastknownplayerlocation is outside of the navmesh (as I would expect it to). But TargetPlayer does remain blue-ish and they move outside of the navmesh without errors/warnings.

Maybe it's intended behavior that when moving towards another actor/character that the navmesh is ignored and that they can move outside of it?

bp3.png (16.5 kB)
avatar image Napoleonite May 03 '16 at 08:00 AM

Okay I tested it again and I replaced the TargetPlayer with TargetLocation (vector) instead and now they do restrict themselves to the navmesh.

Only question now is: intended or bug?

avatar image v.s. May 03 '16 at 09:07 PM

For Vector projection to navigation was enabled by defaults. For Actor mode this test was skipped.

 // fail if projection to navigation is required but it failed
 if (bCanRequestMove && MoveRequest.IsProjectingGoal())

It is not a bug.

avatar image ELKatlan Jul 05 '19 at 05:33 PM

How is it not a bug that using Vector acts different than Actor when that is neither desired or explained? I need to use Actor for moving targets and it's a supported feature, so I'm not sure using a vector solves the issue.

Could you elaborate on that check or point me to the code? Out of context I don't understand what that check means.

avatar image Blindopoly Jul 05 '19 at 05:50 PM

ELKatlan, check out my solution below. It's pretty simple and allows you to use MoveTo Actor.

avatar image ELKatlan Jul 05 '19 at 06:06 PM

Yeah, not a bad workaround. I'd prefer the AI moves to the edge of the navmesh rather than stopping once their target leaves though. Not sure pathing supports that, as I think the path creation fails immediately once it can't find a path to the target, which would fail the MoveTo.

Also curious if your solution works with deceleration. It seems like the AI would stop immediately rather than decelerate slowly if you're using those features.

Regardless, I'd call this a bug.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

Closing question. Short answer: use a vector for the MoveTo-node instead of an actor and it will work. Details are in comments above.

more ▼

answered May 03 '16 at 09:31 PM

avatar image

Napoleonite
595 90 104 155

avatar image Justin.Dooley Aug 08 '16 at 07:00 PM

I've been encountering this problem as well. It seems that even converting my AI to Navmesh Walking and using move to Vectors They still sometimes get forced off the nav mesh when in groups.

If this happens they default to a movement mode of Walking (as they are designed to do) but since there is no nav mesh under them, the AI can't path find out of the space.

avatar image Max974 Jan 11 '18 at 01:42 PM

Hi, I'm encountering this same problem right now, with the MoveToLocation task it works and the Ai doesn't go off bounds. But the problem is that it doesn't offer the same chasing behavior than the MoveToActor offers

avatar image ELKatlan Jul 05 '19 at 05:37 PM

Exactly this. Using a Vector is completely different than an Actor in terms of features. One doesn't replace the other outright. I'm having the same issue on 4.22 in 2019.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Hi,

I had the same problem. But the vector solution was not quite right. So editing some properties of the navigation mesh was able to solve it. Now the enemy does not leave the navmesh when he makes a "moveto an actor task"

alt text

navmesh.png (325.6 kB)
more ▼

answered Feb 20 '17 at 05:24 PM

avatar image

Rinfor
16 1 3

avatar image jimd667 May 24 '17 at 02:57 AM

So I decided to do all the solutions here, set target as vector, set to NavMesh Walking for movement, and set the Observed Paths to 0.1

so far so good, it seems to be working now.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

This is still an issue in 2019. I found a pretty good solution to it that allows you to use MoveTo with an Actor while still preventing the AI from moving off the NavMesh and getting stuck. Basically I just created my own very simple Decorator Called BTD_CanMove where I check that the Actor the AI is trying to move to is also on the NavMesh. I then add that Decorator to my MoveTo node in the Behavior Tree.

alt text alt text

Hope this helps!

more ▼

answered Jun 28 '19 at 04:00 AM

avatar image

Blindopoly
7 1 1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question