ProceduralGraphMover Invariance

Could ProceduralGraphMover be modified to handle GameObject destruction scenarios more gracefully?

When I unload a game map, I set ProceduralGraphMover.target to null. However, due to threading, code continues with stale references to target.

NullReferenceException: Object reference not set to an instance of an object
Pathfinding.ProceduralGraphMover.UpdateGraph (System.Boolean async) (at ./Library/PackageCache/com.arongranberg.astar@1f4b22f35e70/Utilities/ProceduralGraphMover.cs:167)
Pathfinding.ProceduralGraphMover.Update () (at ./Library/PackageCache/com.arongranberg.astar@1f4b22f35e70/Utilities/ProceduralGraphMover.cs:136)

Adding checks can make this class more robust to common scenarios, i.e. target is destroyed.

!if(target)

return

I’ll tag Aron in this to take a look. :+1: Seems straight-forward enough.

1 Like

Good point. I’ll make some changes for the next update.

1 Like