Does It Support Staggered Isometric Grids?

I wanted to know if this project supports staggered isometric grids directly? If not, are there any recommended third-party tools or resources that cater specifically to staggered isometric grids in Unity? Any insights or experiences shared would be greatly appreciated.

Thanks in advance for your help!

Hi

This package only supports rectangular grids. However, wasting some grid area on empty space is not too bad.

Hi Aron, as you suggested I tried to create a rectangular area inside the diamond shape and set all outer nodes as not walkable but it didn’t work.

//...
gridGraph.GetNode(x, y).Walkable = false;

After I print the node it was still true.

Hi

Would you mind showing the full code that you used?

Sure, I tried something like this:

using Pathfinding;
using UnityEngine;

public class GraphConstraint : MonoBehaviour
{
    public float leftBound = -10f;
    public float rightBound = 10f;
    public float topBound = 10f;
    public float bottomBound = -10f;

    void Start()
    {
        GridGraph gridGraph = AstarPath.active.data.gridGraph;

        for (int x = 0; x < gridGraph.width; x++)
        {
            for (int y = 0; y < gridGraph.depth; y++)
            {
                Vector3 worldPoint = (Vector3)gridGraph.GetNode(x, y).position;
                
                if (worldPoint.x > leftBound && worldPoint.x < rightBound &&
                    worldPoint.z > bottomBound && worldPoint.z < topBound)
                {
                    gridGraph.GetNode(x, y).Walkable = true;
                }
                else
                {
                    gridGraph.GetNode(x, y).Walkable = false;
                }
            }
        }

        AstarPath.active.Scan();
    }
}

Hi

By calling Scan at the end, you’ll be destroying all nodes and re-creating it from scratch.
Instead, I’d recommend something like:

AstarPath.active.AddWorkItem(new AstarWorkItem(ctx => {
    var gg = AstarPath.active.data.gridGraph;
    gg.GetNodes(node => {
        Vector3 worldPoint = (Vector3)node.position;
        if (worldPoint.x > leftBound && worldPoint.x < rightBound &&
            worldPoint.z > bottomBound && worldPoint.z < topBound) {
            node.Walkable = false;
        }
    });

    // Recalculate all grid connections
    // This is required because we have updated the walkability of some nodes
    // Note: In a future update, you'll want to change this to gg.RecalculateAllConnections, for performance.
    gg.GetNodes(node => gg.CalculateConnections((GridNodeBase)node));
}));

See also Graph Updates during Runtime - A* Pathfinding Project

1 Like