- Home /
Enemy AI things to consider
I am making a first person shooter something like cysis where you navigate a terrain and enemies will attack you when you get close.Now, i have an enemy soldier with animation ready to use. I want the soldiers to have a small designated area they stay in. Like they patrol a small area and when im in range they take cover and fire at me. I dont need for them to follow me beyond the designated area.
What are things i need to consider using for the enemy AI? Waypoints? Raycasting? Im just not sure. Thank you
Answer by Montraydavis · Oct 25, 2012 at 09:04 PM
Well, not only do you need to consider Waypoints and definitely Raycasting, you need the actual essence of life.
For instance, vision/sight, hearing/range-detection. Things like how to find a target ( Perhaps you should look into NavMesh, or purchase a cheap unity asset. There are plenty ).
There are actually lots of Unity assets to get these jobs done spontaniously, but, if you prefer to code your own classes and what not, here are a few starter tutorials from YouTube.
Here is my own ZombieAI . Keep in mind that this is by no means standard code practice, and I only persuade you to use this as a starting point if you need. But none the less, compile-able.
http://pastebin.com/DczwH38D Zombie Motor
http://pastebin.com/n0bSFXen Zombie Controller
But what I believe you really want is http://pastebin.com/6WfhS8q7 AI . You can at least gain an understanding of what's needed to be known, and improve the flaws it currently has. (ps: runs smoothly though)
http://www.youtube.com/watch?v=POUbAsr-6q4 http://www.youtube.com/watch?v=oytm0eYCQw4 http://www.youtube.com/watch?v=WS8OBRWgbo0 http://www.youtube.com/watch?v=4j94OBb8lDo
Even if you don't want to watch the videos, just skim through them, and point out the parts of the AI system.
Best video I have seen is here : http://www.youtube.com/watch?v=i3HunQfX5fA
Thank you so much i am looking over some of the code you provided. I do want to do this myself rather than use assets. Thank you for all the links and youtube videos i am looking at everything.
They are not a complete necessity, per-say, giving the example above uses only a raycast system. They are however, much more realistic, and efficient.
And you are welcome.
Answer by code-blep · Oct 25, 2012 at 09:38 PM
Hi icelated,
You seem to have asked this question twice. It might be a good idea to remove one of them ;)
Here is my answer in your other post:
To be honest all the above are generally needed. I've looked at this a number of times, and the conclusion I always come to is the keep up the creative flow and reduce development time is to use one of the pre-built ones from the asset store. Here is a selection of the ones I think look good:
http://u3d.as/content/aron-granberg/a-pathfinding-project-pro/2h6
http://u3d.as/content/alex-kring/simple-path/1QM
http://u3d.as/content/rival-theory-/rain-one-/22D
I know they seem a little expensive but considering the time saved it works out to be a massive cost saver!
Hope this little list helps!
Paul
Your answer
Follow this Question
Related Questions
Enemy AI things to consider 1 Answer
how to make a basic AI script in a short time 2 Answers
Enemy Follow Script Help 2 Answers
Waypoint Setup: How? 4 Answers
Stay Back! 2 Answers