A Unity ID allows you to buy and/or subscribe to Unity products and services, shop in the Asset Store and participate
in the Unity community.
Discussion in 'Scripting' started by luhjgh, Sep 29, 2011.
How would I make an AI flee from the player when in a certain distance away from the player?
There are many ways in which you could detect if a player is close. I guess a spherecollider and relying on OnTriggerEnter is a good way to go, just remember to check it the collider is tag "Player". As for the fleeing then that part is hard to answer as we don't know anything about your game. Is it a top-down 2d game? First person shooter? Isometric turn-based RPG? Whatever the case it should be easy enough to get something to move in the opposite direction of the player.