Jump to content

Navigation: How to make AI use doors?


Recommended Posts

I'm currently setting up my AI players with navigation meshes, it works fine so far, but I have problems making them use doorways.

The navMesh adds a distance of roughly 0.5 meters to walls, so the AI does not run into walls or gets stuck, the problem is, my doorways are 1 meter wide so the navMesh does not get generated through them. Only way to make the navMesh go through the doorways is reducing the size to about 0.2 meters, but this makes the navMesh go really close to walls so AI players run into walls constantly and get stuck. So I found there is a link feature which lets you add custom links in the navMesh by hand, like where the AI has to jump etc to get through, it works fine for small barriers with jumping, but it does not work with walking through doors. I think this is because the link feaure also takes into account space to the sides and to the top and decides that the doorways is too small for the player to go through.

So any ideas how to solve this?

Link to comment
Share on other sites

I found the solution, it is a combination of many settings in the navMesh.

You have the actor radius, which defines how big the actor is, it is 0.5 by default since the actor is roughly 0.75 meter thick, 0.5 radius adds a bit buffer so the actor does not get stuck that often, 0.5 + 0.5 = 1.

In my case I used 0.4 actor radius, it is still ok, but also still not enough to make it go through my 1 meter doorway. 0.4 + 0.4 = 0.8 so it should fit through, but it did not.

Then I found that it worked for some of my doorways that have been increased in size a little bit so the door was slightly larger than 1 meter, like 1,14 meter in my case and it worked.

So finally I found out that you need to decrease cell size in the navMesh as well, since cell size is 0.2 by default. In my case this would then be actor radius 0.4 + 0.4 + cellSize 0.2 = 1m so no space left in my 1m doorway for the navMesh to go through, after setting cell size to 0.1 it went through.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...