is an Array the most efficent way of finding the closest gameobject?

I know the method of finding the closest gameobject with FindWithTag, but im programming a Lumberjack for a RTS who should always walk to the closest Tree.

The problem is that its a pretty big world with several thousand trees and also several Lumberjacks and im not sure if its the best way to go through the whole array every time they are searching a new tree.

Im not sure if this will acctually cause performance issues so maybe someone more experienced could answer me this Question :smiley:

IF your trees are actual GameObjects in the hierarchy (and not terrain trees), use Physics.Overlap sphere or other ‘constrainted by Vector3.position’ method.