How to write better AI code?
I'm looking for any ideas on how to condense my AI(NPC) Code. Right now my game is a bit like multiwinia. There is no player interaction at this point, my sphere's just go shoot each other, or grab a spawn point. Their update script is 200 lines long of pretty much if then else statements, and as I build interaction this will just grow.
What are ways I can condense this down to something readable?
AI is a huge topic, I suggest you to read on Finite State $$anonymous$$achines, Decision Trees and Behavior Trees. I find that "Artificial Intelligence for Games" by Ian $$anonymous$$illington to be a great book for AI beginners.
Thanks, I'm familiar to some degree with these. I'll read up and find what works best for me.
Behaviour Tree is a great tool to write complex AIs in an hierarchical manner, so you always have an clear overview on your AI logic. It keeps your code simple and readable. If you are looking for a framework, have a look at Panda BT, it's a scripting framework based on Behaviour Tree. I'm the author, so I'd be glad to answer your questions in case you have any.
I would also suggest Behavior Designer if you want to take the behavior trees route and don't want to implement it yourself, it's on sale right now and the support is great https://www.assetstore.unity3d.com/en/#!/content/15277
Your answer
Follow this Question
Related Questions
Npc and AI 1 Answer
how do i design as Talking Angela App using unity 3D? 0 Answers
Npc with inventory? 0 Answers
Index out of range exeption error help 0 Answers
Why Would Trie Data Retrieval Work in Windows Build but not Mac/HTML? 0 Answers