Search Unity

Navigating on center of the path

Discussion in 'Navigation' started by smtabatabaie, Jan 23, 2019.

  1. smtabatabaie

    smtabatabaie

    Joined:
    May 6, 2013
    Posts:
    45
    Hi, I have an environment which has a set of walls and my player is supposed to navigate on this area.
    My problem right now is that my player navigates on the edges of the walls and what I'm looking for is for it to navigate and move on the center of the corridors.
    Are there any ways to achieve that?
    Thanks
     
  2. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    You might have to take a look at Aron Granberg's A* project or roll your own. The problem you have is that the standard unity pathfinding creates a path cutting diagonally through a corridor, whereas you will want a straight line.
    If I'm not mistaken, the A* project allows you to customise this behaviour to your liking. If not, you'll have to make your own pathfinding, possibly based on the core NavMesh baking Unity provides.
     
  3. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    You can also go a middle way, we used A* Pathfinding but built our own pathfinding ontop of it. Here is a devlog we did about it

     
  4. smtabatabaie

    smtabatabaie

    Joined:
    May 6, 2013
    Posts:
    45
  5. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    The center on path is built into antons framework. SO we dont want to override that even though we have our own pathfinding ontop of his. So what we do is we give all the other paths really high costs that way we know the framework will take the path we want, but it will also use all the built in stuff like not taking the closest way around corners etc.

    If you just want path finding from A to B this just works out of the box with the path finding project. You grow out very quickly from the built in navmesh. I would recomment getting Astar project anyway
     
  6. smtabatabaie

    smtabatabaie

    Joined:
    May 6, 2013
    Posts:
    45
    Thanks very much @AndersMalmgren , I explored anton's framework but couldn't find how to make path on the center of the roads. I'll really appreciate if you can help me on how to do that.