Set max angle to pathfinding behavior

Get help using Construct 2

Post » Mon Apr 15, 2013 7:47 pm

Hello !

I'm trying to use the behavior pathfinding but now it's out of my limit.

I would like to set the max pathfinding angle to for example 10%.

Should I modify theses part of the behavior below ? or should I do in another way?

Thanks in advance for your help.

// Check the box made by the start and dest cells.
          // If the complete box is empty, allow a direct move to target.
          var minX = Math.min(startX, endX);
          var maxX = Math.max(startX, endX);
          var minY = Math.min(startY, endY);
          var maxY = Math.max(startY, endY);
          
          // Path goes out of bounds: no calculable path
          if (minX < 0 || minY < 0 || maxX >= this.hcells || maxY >= this.vcells)
          {
               failCallback();
               return;
          }
          
          var x, y, i, len, c, h, n;

          if (this.diagonalsEnabled)
          {
               var canMoveDirect = true;
               
               for (x = minX; x <= maxX; x++)
               {
                    for (y = minY; y <= maxY; y++)
                    {
                         if (this.cells[x][y] !== 0)
                         {
                              canMoveDirect = false;
                              
                              // Break both loops
                              x = maxX + 1;
                              break;
                         }
                    }
               }
B
5
G
1
Posts: 11
Reputation: 947

Return to How do I....?

Who is online

Users browsing this forum: bluemonkey, MarkThomas, Yahoo [Bot] and 22 guests