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.

Thanks.

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

An AI script is bound to be not a simple script. And i highly doubt anybody here would write you a complete script. This is something you would have to figure out largely by yourself since this is less about coding but rather about logic. What you could try to do is do calculate the distance between your deer and the player. If the player comes near you toggle a boolean variable. Inside of your behaviour routine you would check with an if statement for your bool and have your deer behave accordingly.

Found exactly what I was looking for. http://www.swinburne.edu.au/design/tutorials/P-unity/T-How-to-implement-a-Waypoint-script-in-Unity/ID-260/

1 Answer

1

Hi

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]