NavMeshAdd.ForceUpdate throws null reference exception

NavMeshAdd.ForceUpdate attempts to force updates when you’re in editor, editing a prefab, not surprisingly not having a AstarPath.active. The following quick fix would remove this annoyance:

		/// <summary>
		/// Forces this navmesh add to update the navmesh.
		///
		/// This update is not instant, it is done the next time it is checked if it needs updating.
		/// See: <see cref="NavmeshUpdates.updateInterval"/>
		/// See: <see cref="NavmeshUpdates.ForceUpdate"/>
		/// </summary>
		public override void ForceUpdate () {
#if UNITY_EDITOR
			if (!Application.isPlaying && AstarPath.active == null)
				return;
#endif

			AstarPath.active.navmeshUpdates.ForceUpdateAround(this);
		}

Thanks. I’ll include a fix in the next update.

1 Like