Search Unity

How to make the nav mesh path not hug the edge?

Discussion in 'Navigation' started by TheCelt, Jun 4, 2016.

  1. TheCelt

    TheCelt

    Joined:
    Feb 27, 2013
    Posts:
    742
    Hello i have a nav mesh that goes through a door like this:



    But i hate the way it creates the path, it hugs the corners and looks so unnatural. Is there a way to make the nav mesh select more in the middle of the way rather than the edges so it looks more natural ?

    If i make it any more thin, the characters struggles to fit through which looks even more strange.
     
    Seb-1814 likes this.
  2. Mycroft

    Mycroft

    Joined:
    Aug 29, 2012
    Posts:
    160
    Can you artificially make the nav generated for doors more narrow so that the Agent is more centered when it goes through?

    (only a good idea if you don't have situations where multiple agents are attempting to use the doorway at the same time)
     
  3. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    In my research I've tried several approaches.

    1. make a list of all edges in the navmesh. Get nearest corner + corner normal and extrude out. This works fine except for narrow areas, but it's still pretty dumb.

    2. use navmesh raycast to find points for each corner to move out by. Then when a position is required, sample it as a spline. This is the best approach but requires you do all your movement manually and fetch a list of corners for the path yourself.

    3. as above but exchange spline for steering, which naturally creates an arc, but you will need to do lots more checks so it isn't abnormal looking.