Skip to content

NPC.AISetup

Wesley Haws edited this page Mar 24, 2017 · 17 revisions

NPC - AI Setup


This makes use of the Rain AI system. This will show you how to make use of my already made AI behavior trees to setup a fully functional AI system. The animations will not work if your animator behavior tree doesn't have the correct variables setup in the correct way.


Table of Contents

Rain AI Overview

Rain AI Overview


Rain AI is a Unity Package that will allow you to build AI behavior trees with a nice GUI screen. This requires little to no code experience to complete So that's really nice. Rain AI can be found on the Unity Asset Store and its free!:

https://www.assetstore.unity3d.com/en/#!/content/23569

They have a wiki to discuss basic concepts:

http://legacy.rivaltheory.com/wiki/

but advanced setup features are limited to almost no examples. To help you understand the basics of this though watch this youtube series to get you up to date:

Now if your interested in a bit more these will also help you:

Once you have watched these a lot of the following setup will make a lot more sense. However, I do a lot more than what is just mentioned in these videos because these are "basic" and I'm setting things up a bit more advanced.

Automatic Setup


I have provided exported xml's that you can import to automatically setup your NPC. This still requires you to go through the Install process though. Inside the Rain AI folder of this git repo there are two folder called "Behavior Trees" and "NPC Setups".

To import the NPC Setup "EnemyNPC.xml" file first setup an AI on your NPC object. Then in the gear icon select Import XML.

To Import the Behavior Tree XMLs click on "Open Behavior Editor" Under the mind settings. Then select "Create New Behavior Tree". There should be an "Import XML" button that appears. So name your behavior tree (when making it) the same as what you want to import (not required) as it keeps things consistent and less confusing.

Install Rain AI


  1. Download the package from the Unity asset store using the unity editor.
  2. Import
  • This will create an "AI" and "RAIN" folders. DON'T DELETE THEM!
  • It will also add a "RAIN" button on the top of the editor

Added RAIN button

  1. Select your NPC Object
  2. Open the "RAIN" tab and select Create New > AI
  • This will add an "AI" to your selected NPC Object
  1. Select your player
  2. Open the "RAIN" tab and select Create New > Entity
  • This will add an "Entity" object to your player

Setup BasicMind


  1. On your NPC Object Select the "AI" game object.
  2. If not already selected, select the head picture.
  3. Select the gear icon and select Import XML
  4. Import all of the behavior trees included in this github repo
  5. Setup like the following picture:

Basic Mind Setup

Setup BasicMemory


  1. Select the AI object
  2. Select the light bulb picture
  3. Add the following:

Basic Memory Setup

Setup MecanimMotor


  1. Select AI Object
  2. Select the feet icon
  3. Add the following:

Mecanim Motor Setup

Setup MecanimAnimator


  1. Select AI Object
  2. Select the running man icon
  3. Add the following:

Mecanim Animator Setup

Setup BasicNavigator


Nothing is changed here. The defaults will be fine.

Setup BasicSenses


  1. Select AI Object
  2. Select the Eye Icon
  3. All all of the following (order doesn't matter):

Senses Setup Part 1

Senses Setup Part 2

Senses Setup Part 3


Now you should have a complete setup AI Object.

Clone this wiki locally