LayeredGridGraph max size? IsPathPossible broken

Dear <3

After a long time I have to come back now and hope for your help. I’m making great progress, as you can see here: edited

Everything works fine until i change LayeredGridGraph size from 128x128x24 to anything above.
In the video LayeredGridGraph is set to 128x128x24 (world is 1024x1024x24) and it works.

When i now go to LayeredGridGraph and set size to lets say 512x512x24 (or 1024x1024x24 to enable pathing in whole world) the IsPathPossible(nodeA, nodeB) function is broken. It returns AreaID 0 for both nodes. Which returns in possible path even if not.

As the source comments say, 1024x1024x24 should not be too much?

I dug a lot, but I did not find anything :frowning: Any ideas?

Im still on 4.1.16. I have made modifications in CalculateConnections() and SampleCell() i can provide if you need but from my view there is no context, cause it works with <= 128x128x24.

Thank you extremly for your time and good work!
Cheers!

Hi

I think those changes to CalculateConnections could be useful to see.

Also. Try to call AstarPath.active.FloodFill() before you start to do you calls to IsPathPossible, just to see if that is the problem.

I’m glad to be here again after hardware problems and other things.
Thank you for your immediate feedback after page reload!

I tried playing with AstarPath.active.FloodFill() as you mentioned but it crash when i call it :frowning:

Here the three modifications in LayerGridGraphGenerator.cs

LinkedLevelNode SampleCell(int x, int z)
        {
            if (World.Instance == null)
                return new LinkedLevelNode();

            LinkedLevelNode[] nodes = new LinkedLevelNode[World.Instance.mapHeight]; // Max. mapHeight = 24

            int nodeCount = 0;
            for (int y = 0; y < World.Instance.mapHeight; y++)
            {
                if (World.Instance.mapIndex[x, z, y].walkable) // Is walkable
                {
                    nodes[nodeCount] = new LinkedLevelNode();
                    nodes[nodeCount].position = new Vector3(x, y + 1f, z);
                    nodes[nodeCount].walkable = true;

                    if (nodeCount > 0)
                    {
                        nodes[nodeCount - 1].next = nodes[nodeCount];
                    }

                    nodeCount++;
                }
            }

            return nodes[0];
        }
public void CalculateConnections(int x, int z, int layerIndex)
        {
            var node = nodes[z * width + x + width * depth * layerIndex];

            if (node == null) return;

            node.ResetAllGridConnections();

            if (!node.Walkable)
            {
                return;
            }

            for (int dir = 0; dir < 4; dir++)
            {
                int nx = x + neighbourXOffsets[dir];
                int nz = z + neighbourZOffsets[dir];

                // Check for out-of-bounds
                if (nx < 0 || nz < 0 || nx >= width || nz >= depth)
                {
                    continue;
                }

                // Calculate new index
                int nIndex = nz * width + nx;
                int conn = LevelGridNode.NoConnection;

                for (int i = 0; i < layerCount; i++)
                {
                    GraphNode other = nodes[nIndex + width * depth * i];

                    if (other == null || !other.Walkable)
                        continue;

                    Vector3 otherPosition = (Vector3)other.position;
                    Vector3 nodePosition = (Vector3)node.position;

                    int xN = (int)nodePosition.x;
                    int yN = (int)nodePosition.y;
                    int zN = (int)nodePosition.z;

                    // TODO: Remove try'n'catch

                    // Stair - Forward Connection
                    try
                    {
                        if (World.Instance.mapIndex[xN, zN, yN].name == Items.Names.Stair)
                        {
                            if (otherPosition == nodePosition + Vector3.forward + Vector3.up)
                            {
                                conn = i;
                            }
                        }
                    }
                    catch (System.Exception)
                    {
                    }

                    // Stair - Backward Connection
                    try
                    {
                        if (World.Instance.mapIndex[xN, zN - 1, yN - 1].name == Items.Names.Stair)
                        {
                            if (otherPosition == nodePosition + Vector3.back + Vector3.down)
                            {
                                conn = i;
                            }
                        }
                    }
                    catch (System.Exception)
                    {
                    }

                    // Connect same height
                    if (node.position.y == other.position.y)
                    {
                        conn = i;
                    }
                }

                node.SetConnectionValue(dir, conn);
            }
        }

And in GetNearest(Vector3 position, NNConstraint constraint, GraphNode hint) i changed var graphPosition = transform.InverseTransform(position); to var graphPosition = position;

Thank you very much for your time!
Have a nice day!

Hi

How does FloodFill crash? Do you have a stacktrace and line where it crashes at?
I cannot see anything immediately wrong in your code (though removing the inverse transform in the GetNearest call will break many things, it shouldn’t break IsPathPossible at least).