0 Favourites

Set max angle to pathfinding behavior

  • 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;

                             }

                        }

                   }

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
[BEHAVIOR] Chipmunk Physics
673 82,482
nelostic's avatar
nelostic
Unread hot topic
0 Favourites
[Behavior] LiteTween
672 169,857
manujorgo's avatar
manujorgo
Unread hot topic
564 105,198
rexrainbow's avatar
rexrainbow