Close enought

This was my attempt, I didn’t think about checking if there were less than 2 corners, my bad.

As long as you did put the corner count check in there, that solution works perfectly.

I was curious about the need for this check so I started digging. In their (now “Legacy” 5.4) doc Unity has this check in the example as well, but does not go into why.

Without considering the graph theory it might be tempting to think “but there only needs to be one corner: the one I am moving to” but that is a trap! You are not your corners!

In my playing I found that not only is Unity always holding a 0th corner as the “current position”, but it isn’t guaranteed to be the exact position of the object:
soClose

Presumably they have similar safeguards in place to make sure everything doesn’t just moonwalk away. Either that or the NavMeshAgent is too busy staring at the stars to notice…

Privacy & Terms