Just a suggestion for another approach that is a bit simpler when updating the pathfinding grid when the crate is destroyed:
-
Create a new C# file and call it “PathfindingUpdater” just like in the tutorial.
-
Include the following code:
private void OnDestroy() {
// Get the grid position for this transform
GridPosition gridPosition = LevelGrid.instance.GetGridPosition(transform.position);
// Set the grid position to be walkable
Pathfinding.instance.SetIsWalkableGridPosition(gridPosition, true);
}
Attach this object to the Crate game object in the same place as you added the DestructableCrate and BoxCollider.
Once the crate is destroyed, the pathfinding grid is updated.
The advantage of this approach is that you can attach this script to any desctructable object and it will automatically update the pathfinding grid whenever that object is destroyed. Simple, reusable and no need for having a lot of events for different types of objects.
Hope you found it helpful