ProceduralGraphMover

Hi is this component only available in the Beta? Doesn’t seem to be available in the Pro version that I have. I am not ready to migrate to 2022.

Is it straight forward to modify the GridMover?

OK I wrote this one that seems to work but I don’t know if it is the most performant way of doing it?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Pathfinding;
public class RecastGraphMover : MonoBehaviour
{
public RecastGraph graph;
public float updateDistance = 10;

public Transform target;

Vector3 lastPos;

private void Awake()
{
	graph = (RecastGraph)AstarPath.active.graphs[0];
}

private void Start()
{
	UpdateGraphCenter();
}

void UpdateGraphCenter()
{
	graph.forcedBoundsCenter = target.position;
	lastPos = target.position;
	graph.Scan();
}

private void Update()
{
	if (Vector3.Distance(lastPos, target.position) >= updateDistance)
	{
		UpdateGraphCenter();
	}
}

}

The ProceduralGridMover was renamed to ProceduralGraphMover when support for recast graphs were added.
Your script works, but it will recalculate everything, instead of only the tiles that need to be recalculated.

1 Like

Thanks Aron,

I’m not quite sure what you mean, I am using version 4.2.19 and I don’t have a ‘ProceduralGraphMover’ script.

What is the most efficient way of only updating the tiles that have changed, I am updating the bounds every 16 meters and I noticed that inner tiles usually don’t change and could reuse the existing navmesh, only the edge tiles have changed?

I am developing a game that allows players to build structures anywhere and I would need the tiles that have new or removed objects to be updated as well.

I have read this page but it’s not completely clear about how to only update specific tiles: Graph Updates during Runtime - A* Pathfinding Project

Here’s my parameters I’ve currently set.

Screenshot 2024-01-07 095742

OK, I bit the bullet and updated to 2022 and have the latest beta now.

The only question I have now is the the right approach to triggering a specific cell tile to update say in the case a player modifies the area by placing an object or editing the terrain mesh.

I am aware of the GraphUpdateObjects I’m guessing I just make a Collider bounds that encompasses the area and pass it in?

Exactly. In 4.2.19 it is called ProceduralGridMover, and it only works with the grid graph.

Use the beta version. It’s quite tricky in 4.2.19 to move the graph and only recalculate the tiles that have changed. Several hundred lines of code, at least.

AstarPath.active.UpdateGraphs(new Bounds(...));

will only update the tiles that are touched by the bounding box.

Awesome thanks Aron!