Search Unity

Is it possible to calculate the path?

Discussion in 'Navigation' started by DarkDeivel, Feb 12, 2019.

  1. DarkDeivel

    DarkDeivel

    Joined:
    Aug 31, 2016
    Posts:
    127
    Hello! Doing step by step RPG. Is it possible to calculate the path using only 90 degree angles? My game does not have a grid, I just need my opponents to figure out the path as if there is a grid in the game. To make it clearer I will attach a picture.

    P.S. I've already done the methods for moving around the cells. I need only the enemy to understand when he needs to turn, or go.

    P.S.S. If I use NavMeshAgent.SetDestination (target.transform.position), it will build the most direct path diagonally, but this option does not suit me.

    GridExample.png
     
  2. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    Yeah that's not possible with the default NavMesh system in Unity. Look into A* pathfinding, that's how tilebased games deal with navigation (and what Unity's system builds on top of, unfortunately with too much stuff over it to use for this kind of stuff).