Click here to Skip to main content
15,881,669 members
Articles / Artificial Intelligence

Unity AI Programming Essentials–A Review

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
10 Jan 2015CPOL7 min read 15.1K   4   3
A review of Unity AI programming essentials

This article is in the Book Review chapter. Reviews are intended to provide you with information on books - both paid and free - that others consider useful and of value to developers. Read a good programming book? Write a review!

I can see a light at the end of the tunnel. As I’m nearing the journey of my marathon book writing spree. I’m taking a little time out to read a few other books on Packt’s library, this time in one of my favorite areas, AI.

Image 1

Unity AI Programming Essentials

AI is hard, anyone who says anything otherwise is either a rocket scientist or works for an AI firm doing it day in and day out.
It can take many forms, from path-finding to NPC behaviour and in all cases it takes some serious effort (or at least a few hours trolling AI tutorials) to figure it all out and even then, it takes ages to debug. It is yet another one of those areas where you either need a dedicated developer, a fantastic framework or some lousy cut and paste job to get through it.

Image 2

With so many options to choose from these days, it’s hard to know where to turn, especially with advanced systems such as AI. So it’s a welcome find to grab a book that focuses on just AI systems and the AI packages out there. Even better if it has lots of working examples on the multitude of different AI problems we face in modern gaming.

So let’s break down what this book has to offer above the competition.

Image 3

Here’s a brief run through what all the chapters are and what to expect from them:

Chapter 1 “Pathfinding”

The first style of AI most wouldn’t consider actual AI is pathfinding, basically it involved getting a subject from point A to point B without walking on things it shouldn’t (like walls) and in a lot of cases in the shortest path/time. This chapter then walks through some examples using the 3 AI Asset store packages the book covers (Quick Path, React, and RAIN AI) in a clearly explained fashion. Finishing off with a nice comparison between what each of the packages offers in this area.

Chapter 2 “Patrolling”

Expanding on the examples in Chapter 1, in this chapter, we cover adding waypoints and some basic behaviours to AI agents. Each example again working through each of the three AI asset packages.

Chapter 3 “Behaviour Trees”

A core part of any intelligent AI is the need to have more complex behaviour support. For an AI not to be just aware of where it needs to get to but of other AI agents that are active in the scene. In this chapter, we go further and look at some more complex behaviours for the NPC AI. However, this chapter only focuses on the Free RAIN AI framework.

Chapter 4 “Crowd Chaos”

For true NPCs to believable, they need to appear as they are getting on with their own lives and not just following a predefined script, making their own choices and getting on with things. So in this chapter, we look at giving NPC AI more intelligence and variant behaviour trees with examples in React and Rain AI.

Chapter 5 “Crowd Control”

Now chaos is one thing but in order for any crowd system to work, it has to have a certain level of control. If every Ant in an Ant colony went about their lives their own way, there would be chaos. So this chapter focuses on building relationships between NPC AI to organize crowds in to a purpose. Giving examples using an Ant Colony as a great example using two different Unity Asset packages (Fame Crowd Simulation API and ANT-Op) which have specific implementations for crowds.

Chapter 6 “Sensors and Activities”

Without AI happily wandering around our scene, there are happy days ahead. It would be nicer if they also had things to do and look out for, whether that’s chasing down the player when they see them or a switch on the wall they can flick. In this chapter, you focus on building a few extra senses for your NPC AIs using RAIN AI’s features.

Chapter 7 “Adaptation”

Delving further in to the AI realm, this chapter looks at some of the more advanced RAIN AI capabilities including the ability of AI to learn and be more aware of their environment.

Chapter 8 “Attacking”

This last behaviour module focuses on a specific AI implementation that is used in a lot of games these days. It covers generic attacking patterns for AI including ducking and covering, making the AI isn’t just suicidal in its attempts to down the player but will look after itself and run away when it needs to. (My mind always turns to Monty Python with this kind of logic (http://bit.ly/AngryRabbit).

Chapter 9 “Driving”

Stepping back from all the chaos and fighting, the book looks into another branch of AI, a more peaceful and calming area, Driving!, looking at car steering behaviours and object avoidance whilst taking into account the physics conditions of the vehicle you are in and using a Unity Navmesh to great effect.

Chapter 10 “Animation and AI”

RAIN AI also has the ability to integrate with both Unity’s old animation system and the more modern Mecanim system, allowing you to play different animations in relation to different AI states. Here the chapter walks through a decent demo using Unity’s own assets to show you how to set all this up.

Chapter 11 “Advanced NavMesh Generation”

Throughout the book, NavMesh’s have been used to great effect to keep NPC AIs on the straight and narrow. In this chapter, you will walk through some of the more advanced RAIN IA NavMesh options and what they mean for your titles..

Image 4

I had high hopes and expectations for this AI title. AI is a very hard subject to get right and there are a lot of twists and turns along the way. Overall, I think the authors have done a good job of focusing on several difficult AI problems and walked you though several tools you can use to make the job a lot easier.

While the examples were thorough, the main issue in this title is the writing style, many times I had to re-read sections because I had a hard time understanding the language used, not sure if this was the original intent or something that was introduced later in the book’s publication (having full experience of that).

The other issue with the title is that most of the Assets used (which are paid for) are only there to show how good RAIN AI is (which is free). This isn’t to say it was written to promote RAIN but they just take up space that could have been better used to explain more about what is going on.

All in all it is a good book (albeit very short for 11 chapters) with some very well thought through examples and you can get a lot from it.

Pros

  • A lot of varied examples which are clearly walked through
  • Focuses on the concepts of AI without scaring the reader too much
  • Makes good alternative uses of NGUI

Cons

  • Too many different frameworks covered and doesn’t cover Unities own features much. Should have stuck to just RAIN AI (free) and Unity
  • Some people might have trouble with the language (just takes a few extra reads though)

Image 5

All in all, this is still a book I would buy. There are a lot of touch AI concepts covered in this book with clear and concise examples. The title is a bit tainted by the (in my opinion) wasted space on other paid frameworks that are not as good as the free assets (RAIN AI) and the style of language used (which I would have gotten torn to shreds for in my own titles, I find this concern particularly odd).

In the end though, it’s all about the AI and in this capacity the authors do a good job of breaking down a huge and complex area.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect ZenithMoon Studios
United Kingdom United Kingdom
Long-time game developer / IT maniac.
By day I architect, design, build and deliver enriching Mixed Reality solutions to clients, bringing the work of AR/VR to light in new and interesting ways, by night I Masquerade as the Master Chief of ZenithMoon Studios, my own game development studio.

At heart, I am a community developer breaking down lots of fun and curious technologies and bringing them to the masses.

I'm also a contributor to several open-source projects, most notably, the Reality Toolkit and all the services provided by the Reality Collective, The Unity-UI-Extensions project, as well as in the past the AdRotator advertising rotator project for Windows and Windows Phone.

Currently, I spend my time fulfilling contracts in the Mixed Reality space (primarily for an XR experience firm called Ethar), writing books, technically reviewing tons of material and continuing my long tradition of contributing to open-source development, as well as delivering talks, but that goes without saying Big Grin | :-D

Mixed Reality MVP, Xbox Ambassador, MS GameDevelopment Ambassador & Best selling author:

[Accelerating Unity Through Automation](https://www.amazon.co.uk/Accelerating-Unity-Through-Automation-Offloading/dp/1484295072/ref=rvi_sccl_3/262-0817396-1418043)
[Mastering Unity 2D Game Development] (https://www.packtpub.com/game-development/mastering-unity-2d-game-development)
[Unity 3D UI Essentials] (https://www.packtpub.com/game-development/unity-3d-gui-essentials)

Comments and Discussions

 
QuestionSounds Good Pin
Paul Conrad5-Sep-15 19:10
professionalPaul Conrad5-Sep-15 19:10 
AnswerRe: Sounds Good Pin
Simon Jackson5-Sep-15 22:08
Simon Jackson5-Sep-15 22:08 
You can check out my other reviews (posted here or on my blog)
Obviously I'll recommend mine (Mastering Unity 2D Game Development and Unity 3D UI Essentials)

Simon (darkside) Jackson
ID&Xbox MVP & Best selling author
[Mastering Unity 2D Game Development] (https://www.packtpub.com/game-development/mastering-unity-2d-game-development)
[Unity 3D UI Essentials] (https://www.packtpub.com/game-development/unity-3d-gui-essentials)
GeneralRe: Sounds Good Pin
Paul Conrad6-Sep-15 6:29
professionalPaul Conrad6-Sep-15 6:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.