If close to player then find the closest object with a tag within a certain distance

Hello i need help on how can make it so if an object gets close to the player within a certain distance then go find the closest object with a “Hide-able” tag within a certain distance.

from my understanding, you can use Physics.OverlapSphere(yourOrigin, detectionRadius, yourHideableLayermask) to check if there are any hidable objects nearby or not then you can do a simple for loop to check which one of the objects are closer to your position then you simply move there.

First I would start with the 10 Trillion tutorial videos available on google.com

This assumes you understand the basics. If you don’t, go here first https://learn.unity.com/

There are different ways to do this, but the two most obvious would be (1) using colliders (see https://docs.unity3d.com/ScriptReference/Collision-collider.html) and (2) a list of game objects that might come close to the player, whereas you would regularly loop through such a list and check distance. The latter option might prove suboptimal in case you had an overwhelming number of items.