I am making an RTS where I have indirect control over my humans and am having problems finding the nearest available resource as opposed to just the nearest available.
Basically, if a human decides they want to chop a tree I mark it as claimed. Then if another human is looking for a tree to chop, they should find the closest tree that is not claimed. I think my problem is syntax, I am currently trying to add all the unclaimed to an array then sort by nearest but just can't seem to crack it.
Thanks in advance for any advice, this has been driving me nuts for two days.