Help with AI that roams randomly and reacts to player

Hi all,

I’m in the process of creating a game where the player explores an island and examines objects. I want to include animals that roam around in their own part of the island and react to the player by moving away from them and sometimes approaching them. Any help will be greatly appreciated.

Thanks in advance,

Takz

AI behavior is typically complex if it is to approach a simulation of real-life behavior, human or animal. Here’s how you could start (no actual pathfindign involved):

If the player is not seen:
find a random Vector3 coordinate on the ground in a ceratin radius around the animal
if this spot is reachable, move there (or just turn to a random direction)
wait a set amount of time
repeat

if the player is seen:
move towards him until he is a set distance away (Vector3.Distance)
if he is nearer, move away from him.