[IndexOutOfRangeException] RecastTileUpdateHandler

The RecastTileUpdateHandler throws an IndexOutOfRangeException. We’ve pulled the script from the Example Scripts to update our Recast Graph.

[Exception] IndexOutOfRangeException: Index was outside the bounds of the array.
RecastTileUpdateHandler.ScheduleUpdate()    Assets/Scripts/Systems/EmergencyExit/RecastTileUpdateHandler.cs:107
105:   for (int z = touching.ymin; z <= touching.ymax; z++) {
106:       for (int x = touching.xmin; x <= touching.xmax; x++) {
-->107:           dirtyTiles[z*graph.tileXCount + x] = true;
108:       }
109:   }

RecastTileUpdate.ScheduleUpdate()    Assets/Scripts/Systems/EmergencyExit/RecastTileUpdate.cs:56
54:   } else {
55:       if (OnNeedUpdates != null) {
-->56:           OnNeedUpdates(new Bounds(transform.position, Vector3.zero));
57:       }
58:   }

RecastTileUpdate.Start()    Assets/Scripts/Systems/EmergencyExit/RecastTileUpdate.cs:35
34:   void Start () {
-->35:   ScheduleUpdate();
37:               var placeable = GetComponent<Placeable>();

Hi

It looks like you have made some heavy modifications to that script. The original script doesn’t even have a ScheduleUpdate method, nor is any callback named OnNeedUpdates called.

I’m going to forward that to my collegue :slight_smile:

Hi!

Almost nothing of this script has been modified afaik.
Here’s the link to your script: https://arongranberg.com/astar/docs/class_pathfinding_1_1_recast_tile_update.php

It appears the methods are the same. :slight_smile:

Ah. I misread the script name.

Hm… Are you re-scanning/changing the dimensions of the graph during runtime by any chance?

We are creating all graphs during runtime and are scanning during runtime. All our graphs work on dynamically created and/or loaded scenes. Once a graph is created we are not changing it’s dimensions on purpose - does it do that during a scan?. We are creating additional Recast Graphs to operate on.

Try to log

Debug.Log(touching + " " + graph.tileXCount + " " + tileZCount + " " + dirtyTiles.Length);

right after the

var touching = graph.GetTouchingTiles(bounds);

line

1 Like