title: Find path avoid soft collisions
body: <p>I have x,y dashboard 10x10. I have array of destinations x,y from which I need to find closest and its path. </p>
  
  <p>I also have array of soft collisions and array of pernament collisions. </p>
  
  <p>I'm using pathfinding package to find the path. I'm setting pernament collisions like so:</p>
  
  <pre><code>//set collisions
  for(let i = 0; i &lt; mapData.collisions.length; i++) {
      grid.setWalkableAt(mapData.collisions[i].x, mapData.collisions[i].y, false);
  }
  </code></pre>
  
  <p>and I'm finding actual closest coordinate and its path like so:</p>
  
  <pre><code>//find actual closest coordinate and its path
  for(let i = 0; i &lt; destinationCoords.length; i++) {
      currentGrid = grid.clone();
      currentPath = finder.findPath(heroCoords.x, heroCoords.y, destinationCoords[i].x, destinationCoords[i].y, currentGrid);
  
      if(currentPath &amp;&amp; currentPath.length !== 0 &amp;&amp; currentPath.length &lt; closestPathLength) {
          closestPathLength = currentPath.length;
          closestPath = currentPath;
          closestCoords = destinationCoords[i];
      }
  }
  </code></pre>
  
  <p>now the problem is that if i have following dashboard:</p>
  
  <p><a href="https://i.stack.imgur.com/gETuq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gETuq.png" alt="enter image description here"></a></p>
  
  <p>where yellow is start point, green is end point and pink is soft collision it will just go through pink tile.</p>
  
  <p>But what I want to achieve is to avoid soft collisions. So the path would be:</p>
  
  <p><a href="https://i.stack.imgur.com/ElWcQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ElWcQ.png" alt="enter image description here"></a></p>
  
  <p>But when there is no other option the path would be:</p>
  
  <p><a href="https://i.stack.imgur.com/3bV5y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3bV5y.png" alt="enter image description here"></a></p>
  
  <p>Any ideas?</p>