I am trying to make a enemy that follows the closest object in its range without a specific tag. i tried googling but all of the answers were just finding objects with tags. Can anyone please help?
This function will provide you a list of all collider objects within a given radius:
Alas, the resultant list is NOT(I think) ordered in any particular way, so you would still need to loop through the results to find the closest object. Another limiting factor is that you must specify a radius: if no objects are found, expand the radius and try again. (but be careful with that; I suspect this is a fairly expensive function to call)
Note: this solution requires that the GameObject to be found has a collider component attached to it.