I am using Unity NavMesh to control my units.
I am running into an Issue when updating Navmesh at runtime, It seems agents re-calculate their path whenever it is modified, which makes sense, but it causes this line (check if unit is on last corner) to return an IndexOutOfBounds
error:
agent.steeringTarget == agent.path.corners[agent.path.corners.Length - 1]
I guess something is happening while re-calculating path that might mess with this for 1 frame. I solved this by putting a try/catch around it, but is there some better way I can manage this so I don't get the error at all?
=
instead of a==
? \$\endgroup\$ – Kevin Jul 10 '20 at 18:21