- Home /
 
               Question by 
               MacAndCheese96 · Mar 13, 2020 at 07:46 AM · 
                2dmovementtilemappathfinding  
              
 
              How to highlight only walkable path on tilemap,Sorting walkable path on a tilemap
Hello, i'm trying to sort the walkable tiles on a tilemap based on move points (int) but i'm currently stuck and have no idea what to do next. This is my code and my current result, the second pic is what i want to achieve. Thanks. ` private List FindNeighbors(Vector3Int parentPosition) {
     List<MapNode> neighbors = new List<MapNode>();
     
     for (int x = ((move + atkRange) * -1); x <= move + atkRange; x++)
     {
          for (int y = ((move + atkRange) * -1); y <= move + atkRange; y++)
          {
             
              if (Mathf.Abs(x) + Mathf.Abs(y) > move + atkRange)
              {
                  continue;
              }
             Vector3Int neighborsPos = new Vector3Int(parentPosition.x - x, parentPosition.y - y, parentPosition.z);
             if (x != 0 || y != 0)
              {
                  if (neighborsPos != startPos && groundMap.GetTile(neighborsPos) && !obstacleMap.GetTile(neighborsPos))
                  {
                      if (Mathf.Abs(x) <= move && Mathf.Abs(y) <= move && Mathf.Abs(x) + Mathf.Abs(y) <= move)
                      {
                          MapNode neighbor = getNode(neighborsPos);
                          neighbors.Add(neighbor);
                      } else
                      {
                          MapNode neighbor = getNode(neighborsPos);
                          atkRadius.Add(neighbor);
                      }
                  }
              }
          }
     }
     return neighbors;

 
                 
                pathfinding-error.png 
                (102.7 kB) 
               
 
              
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                