Search Unity

FPS Microgame: How to stop larger enimy from navigating though small doorways.

Discussion in 'Navigation' started by BrBarry, Jun 7, 2022.

  1. BrBarry

    BrBarry

    Joined:
    Jul 16, 2019
    Posts:
    10
    I have enlarged a couple of the enemy HoverBots (bigger than the doorways) they still navigate through the doorway and ghost through the wall. How to stop? The doorway has a mesh collider, which I assumed would create a barrier.

    Any suggestions.
     
  2. Inxentas

    Inxentas

    Joined:
    Jan 15, 2020
    Posts:
    278
    You will probably want to configure your NavMeshSurface for multiple agent types.

    Click on the object that has your NavMeshSurface component. In the inspector you can see that it has only one Agent Type, which is named Humanoid. The settings for this agent type are applicable to most humanoids.

    Click on the dropdown meny and select Open Agent Settings. Then at the top, you see a List with one entry: humanoid. What you want is to add new agent types with their own radius, height and step height. So make a new agent, call it HoverBot, and give it a height larger then the height of your door frame, and a radius applicable for it's size.

    The HoverBot is clipping through stuff because the NavMeshSurface treats it as a humanoid, and thus it can pass under and through holes that a humanoid could also pass through. Once you have assigned the HoverBot settinngs to your Agent it's gizmo's should represent those settings, and you can see the cilinder that represents your NavMeshAgent being larger then that of a humanoid. It will no longer be able to pass through the doorway.