Need to delete previous paths?

Hi, I have followed some of the tutorials and examples and got a really good Diablo style “click-to-move” control scheme working for my player. I click on the ground, he finds a route to the point with no problem. I’ve noticed in the console though that each time he’s sent on a new path it says; “Path Completed” then “Path Number 1”, and each subsequent click it’ll increment, “Path Number 2, 3, 4” etc. I was just wondering if this is correct behaviour, or should I be deleting each of these paths manually somewhere along the line? In a long scene where the player is clicking lots, the number of paths could increase a lot higher so just wanted to be sure these old redundant paths aren’t all being stored somewhere and lead to leaks or something.

Sorry if a dumb question :wink:

Hi

No, they are not stored, paths have numbers for debugging and internal identification purposes (integers instead of references to avoid memory leaks actually).

When reaching 65536 (2^16) the path count will overflow and be reset to zero, a small cleanup operation will also be performed at that point to make sure resetting the path numbers will not cause odd behavior.

Paths can be pooled however, (see page on pooling in the docs). That is advanced usage to avoid the constant creation of new objects which can be a problem since the GC might then be called more often (and this is only a problem because Unity does not seem to want to upgrade to a newer version of mono which has better garbage collector).