AI is "attracted" by wall

Again I have problems with the way my AI moves. I just use a regular AIMoveTo Node in the AIController. I recorded a video for you:

Every time I right click (I click only once!), the AI should move to where my mouse is. You see that in the moment I right click a debug point is drawn. I let the AI move from left to right and right to left, but for some reason it tries to walk against the wall! Once it comes close to the wall, it rotates in the direction of the wall, it looks like some attraction the wall has on the AI. As if the AI would be magnetically attracted to the wall. But why? The wall is just a mesh I placed in the level, its affecting the navmesh, you see the navmesh debug on the video, it looks all fine.

I have actually tried to get the fail state from the AIMoveTo Node, but it does not fail! It fails once I click somewhere again to give the AI a new move command, but before that, it just does - nothing. AI either idles around, but the MoveTo neither succeeds nor fails. You see that sometimes it seems close to stop moving, but then suddenly rotates away from the wall again and continues to move to the target.

I actually adjusted some of the navmesh generation settings (in the project settings) to make the navmesh fit my needs, but could this cause such a problem like this? The only special setting might be the cell size which I lowered to 5 since otherwise the navmesh would not appear on the stairs.

http://puu.sh/jGCqb/d388b02ed7.png

Looks to me like you just don’t have the agent radius of the nav mesh matching your character’s capsule radius. This results in the agent thinking it can walk closer to the wall than it can, and then catching on it as a result. I think the agent radius in the nav mesh should be >= the radius of any character that will use that nav mesh.

Now, in your settings screenshot it actually looks like you already have a large radius configured, but then I don’t know what your world/character scale is, and from the video it certainly seems like this is the issue.

The capsule radius of the pawn is 65, so a lot less than the 100 I have set in the nav mesh settings.

Hello ,

Could you try lowering your “Max Simplification Error” to 1 and see if your issue persists? If this does not solve, i have a few questions that will help narrow down what issue it is that you are experiencing.

Quick questions:

  1. Can you reproduce this issue in a clean project?
  2. If so, could you provide s detailed list of steps to reproduce this issue on our end?
  3. Could you provide screen shots of any blueprints that may be involved?

Hi Rudy,
I have tried setting the Max Simplification Error to 1 and it does not change anything regarding how the AI moves.
I actually have no idea whether I can reproduce this in a clean project since I don’t want to spent time on trying it, but I’m pretty sure it would happen the same there. I just hoped someone like Mieskzo would just take a look at the video and then would know what’s the cause for this, without much trying and searching. I don’t have the time for spending it on more hours of trying around to find what exactly the bug is.
Thanks!

Hello ,

If you replace the current model that is being used with the default character from the third person template does this issue still occur?

It’s hard to see for sure, but in the video it looks like you have the default material on the ground so I’m guessing those grid squares are 100 units wide? If so, then the gap between the wall and the nav mesh should be about the same size, but it’s clearly smaller.

Put another way, with a nav radius of 100, your stairs would need to be more than 200 units wide for the nav mesh to generate a path up them. Are they that wide? If not, then the nav mesh is for whatever reason not being generated correctly for the radius you’ve specified. Do you have multiple nav meshes by any chance?

It does not occur with the default character, unless I increase the capsule size. So the capsule size seems to be the cause of the problem. Default is radius 34, I set it to 65. But as i said above in the navmesh settings I actually set the agent radius to 100, so 65 should be totally fine…

I only have one single navmesh. I actually need the navmesh to generate on the stairs, so if it would not do it, then I would have another problem. I have the default material on the ground, that’s true. If one square is 100 uu, then the stairs are 120 uu wide.

I always set all the navmesh settings in the project settings, but the settings in the RecastNavMesh in the level seem to differ here, the agent radius is only set to 35 there. The problem with the RecastNavMesh is that if I change settings there they get reset back to default, which is 35 for the agent radius. So the agent radius I specify in the project settings does not seem to have any impact and the agent radius I specify in the RecastNavMesh get’s reset after a restart.

The changes I make in the RecastNavMesh also dont get applied after I start the game. In the editor they get applied, but once I start the game still the default values are used (which is 35 for the agent radius). So for example I set an agent radius of 100 in the project settings, and 100 in the RecastNavMesh, but after hitting play, the navmesh still generates same as if it would be 35.

And even if it would not get reset, I need the navmesh to generate on the stairs and also on top of the wall. For the stairs, well I could just use stairs which are wider. But for the wall, one wall segment is 100 UU wide, so there someone with a width of 65 should be able to walk, but if the agent nav radius is set to 65 I don’t get any navmesh on top if it, since it would need to be at least 65*2 wide. Actually, a human with a width of 150cm could even walk on a rope with a width of 1cm!

But how do I tell this to the navmesh?

Okay in that case this is definitely the issue. But like you say there are some related issues and it may not be so easy to get things to work as you want.

First off, the nav mesh setup in the editor is really confusing. I honestly don’t understand how the nav mesh defaults within project settings fit into it all. I actually ignore the settings under Navigation Mesh, and configure mine under Navigation System settings. Add an entry to the Supported Agents array and set up the radius and other stuff in there. Then save and restart the editor. You should then have a navigation mesh in the world outliner with settings matching the ones you gave.

Now what I’d expect if you had agent radius set to 100 is that you’d get no nav mesh on the stairs or on the top of the tower. This is expected behaviour. I had a discussion with Mieszko in another question a while back - basically it won’t generate any nav mesh within Nav Agent Radius units of either a wall or a drop off, and there’s no way to override this. Also, sometimes even if there should be just enough space for an agent in a given area, you might not get any mesh generated if the cell size isn’t small enough.

So there’s basically an inbuilt limitation to how confined an area you can have an agent of a given size navigate in. You can’t set it up so a character walks along a beam that is narrower than its own collision capsule, for example.

In your case, I’d consider whether you really need the capsule radius to be so big. 65uu radius means a diameter of 130uu, which is really wide if your character is in the region of 150 to 200uu in height. If you make your capsule radius and Nav Agent Radius 50, maybe a bit smaller, you should be able to generate nav mesh on the stairs and on the top without having a ridiculously small cell size.

Hello ,

Does the sword and shield of your character have collision? If so, if you turn this off does the issue still occur? My thoughts are that these are not accounted for by the capsule and may be getting caught on the geometry as the character tries to pass.

@

I have added one agent now in the “Navigation System” settings in the project settings, and after restarting the editor I indeed get the navmesh generated “correcty”, although it’s really annoying to use the “Navigation System” settings for this since I have to restart the editor any time I want to change some settings. It now looks like this:

http://puu.sh/jMgY8/58707aa098.png

So I made the stairs really broad now, otherwise there would no navmesh generated on top. Of course this is super unrealistic, now all units would exactly only walk at the center of the stairs, it will look strange and the player will ask himself why the AIs don’t use the space they have, at least walking near drop of side should be no problem for the AIs.
I’ve also found the discussion you mentioned:

So unfortunately it just does not seem to be possible to change this, it seems Epic does not want to see “Tightrope Walker Simulator 2016” made in UE4 :confused:

It should be possible to workaround this with adding invisible blocking geometry around the ledges which will make the navmesh generate there too, although that’s a pain to setup for me since all the walls are one single (or more exactly two) Instanced Static Meshes, so I have to add another ISMC where I add the blocking geometry for navmesh generation every time I add an instance to the real ISMC.

I actually need the collision size of the character to be so huge for root motion animations, although I probably could always just adjust the size depending on whether I currently play the animations or not…

Thanks a lot for making me aware of the issue, at least I now know the cause for my problem and this also results in possible workarounds :slight_smile: If you would not have pointed me in the right direction I would probably still search for the reason for the strange behavior. So thank you!

@Rudy

The sword and shield meshes do not have any collision at the moment. I always had in mind collision should only be enabled for the capsule on a character and nothing else.
If you could add a feature request for the navmesh being generated near ledges and also enter bug reports for the resetting navmesh settings I mentioned that would be awesome :slight_smile: Thanks!