Simple AI...wandering aimlessly and flees from player when near player

im trying to make an Ai where it wanders aimlessly and it gets close enough to the player it flees.I dont know where to start as im new to unity. please help!

'Steering behaviors' are a common solution to this sort of problem. I think there's a steering behaviors library that can be used with Unity (and there's plenty of info on this topic available online as well).

In this case, you'd use the 'wander' behavior when the object is outside of the player's sphere of influence, and otherwise use the 'flee' behavior.