How to create a Animal like AI? For Hunting game.

Hi, I am making a single player hunting game. Everything has been going pretty smooth so far, although now I am kind of stuck. I can make a AI to follow me and move towards me… But I can’t figure out how to make it run away…

What I want my “DeerPrefab” to do is wander around (doesn’t have to be highly detailed or anything) just simple for now) and when my player comes with in a certain distance (I prefer a random range) The deer will “Notice Me” and run away. (Increasing speed from walking to running speed.)

If I could figure out how to write AI I would want to write a script to where the deer walks around stopping every now and again to rest (Laying animation would play) then sometimes stopping in the middle of a field and a eating grass animation would play. If my player was close but crouched then I can get closer than I would be able to if standing… Just kinda realistic but I have no clue on how to go about doing that or learning how. So if knows of or can think of a simple script to make the deer walk, then run away if i come too close, please help me out.


PS: I Code in C# if you can write in C# format that would help.


I may support you with some good ideas with the whole hunting game concept not actually coding. This is the link to the main video game concept, I will give more in-depth game-play concept if you like: [9668-hunting+simulator.pdf|9668]