RAIN{ONE} - Support - Rival{Theory}

quarterceladonΚινητά – Ασύρματες Τεχνολογίες

10 Δεκ 2013 (πριν από 3 χρόνια και 8 μήνες)

492 εμφανίσεις

1
RAIN{one}
Beginners Guide
http://support.rivaltheory.com/
Welcome to RAIN{one}
Introduction
Rival{Theory} presents RAIN{one}, a game AI Platform deployable on virtually every platform; Xbox 360,
Playstation 3, Wii, PC, Android, iOS and more. In addition, RAIN{one} works on both the free and Pro
versions of Unity. RAIN{one} is a Unity add-on that allows developers to create and customize artificial
intelligence as part of a video game scene. With RAIN{one} developers can quickly and easily create
characters with the ability to sense, make decisions, and move about the game world. RAIN{one} has been
created for the full range of Unity developers.
This Beginners guide will cover the features of the RAIN{one} software, walk you through installation and
provide you with a “Quick Start” tutorial at the end, which will tie everything together.
Features
RAIN{one} includes a number of key features designed to make adding artificial intelligence to your project
simple, accessible, and easy-to-use. The following is a list of these features and a brief description of each.
The walk through included in this guide will introduce you to some of these features. If something sounds
complicated, don’t worry, each one of these features is fully explained in the RAIN{one} User Manual.

• One-Click AI setup:
Developers can turn nearly any game object into an AI with a single
click.

• Behavior Trees:
The Behavior Tree Editor allows for easy creation, maintenance and
modification of complex decision making.


Primitive Actions:
Easily add movement, animation, sound and detection to your AI.

World Markup:
Developers can easily setup their game scene to interact with and trigger AI
functions.
2
RAIN{one}
Beginners Guide
http://support.rivaltheory.com/
Installation
Buying Rain
From within Unity open the Asset Store located in the Window menu. From within the Asset Store search
for and click on RAIN{one}. Click the “Buy” button. RAIN{one} will download after check out. When it
had downloaded successfully the “Buy” button will change to read “Import”. Click the “Import” button to
install RAIN{one}.

Confirming Installation
To check that RAIN{one} has installed correctly, click on the menu in Unity and locate the “RAIN” menu
item from the components menu.
3
RAIN{one}
Beginners Guide
http://support.rivaltheory.com/
RAIN{one} Concepts
What Is An AI?
An AI is a character or game object that supports behavior generated action. We usually think of an AI as
a computer-controlled character which needs to think and act on its own. However, “AI” can also include
cameras, scene objects (cars, animals) or any other game object requiring intelligent action.
RAIN{one} and Unity
How RAIN{one} Works Within Unity
RAIN{one} uses an Agent to coordinate the functions of the body and mind of the character or game object.
As information is sensed from the game-world the mind will select which actions to take. The Agent then
coordinates these actions with the body.
Sensing and Behavior
RAIN{one} allows the character or object to sense what is going on in the world around it. After receiving
this information the Agent coordinates the body and the mind to produce the desired action.
Sensors
Sensors provide a mechanism to detect information in the world and make it available to the mind. This
information can be detailed numeric data or, simply, the identification of a target or cover point.
Aspects
Aspects are what the Sensors detect. Aspects are set up by you, the developer. Aspects can be complex ideas
like, “armed and dangerous” or basic identifiers, like “tree”.
4
RAIN{one}
Beginners Guide
http://support.rivaltheory.com/
Minds
Simple Mind
The Simple Mind is basically a container for a set of behaviors. As the game object moves through the world
and senses the environment the Simple Mind will process this information and select the best action from the set
of behaviors. Most of what the Simple Mind is capable of is defined in developer written code.
The Behavior Tree Mind
The Behavior Tree Mind is capable of much more complex decision making. Behavior Trees start with a basic
task (“Go to the car”) and then break down into smaller tasks which end in actions. Whereas the Simple Mind
may simply select one action, “Go to the car”, the Behavior Tree Mind is capable of advanced decision making
that makes any action, even the action of moving to the car, much more intelligent.
RAIN{one} makes designing Behavior Tree logic easy through a point and click Behavior Tree Editor. This
editor also allows developers to quickly and easily maintain and re-use Behavior Tree logic.
Movement and Actions
Movement
Movement is guided by Waypoints, which are hand-placed throughout the game world by the developer. After
Waypoints are set up, the AI can then process the scene and figure out the best route.
Actions
Actions themselves are where you, the developer, get to be creative. Actions are where the AI logic meets code.
These can be simple things like “Move along the path” or more complex actions like “Destroy the enemy”.
5
RAIN{one}
Beginners Guide
http://support.rivaltheory.com/
Getting Started: Walk Through
Creating AI - Adding a Simple Mind
You can add AI to any game-object in just two steps. The following steps will show you how to add a
Simple Mind to an object. Most of the AI functions the Simple Mind is capable of have to be coded by the
developer. However, some basic functions can easily be achieved with the Simple Mind, as you will see in
the Movement section.
In this walk through we will be using Unity’s AngryBots project. Feel free to use your own project, but keep
in mind that objects and locations referenced in the walk through are AngryBots specific.
1. Select the ‘Player’ game object
Select the Player object from the Hierarchy Window.
2. Add a Mind to the Object.
Navigate to the RAIN menu, located under the
Components menu, and select Create AI --> with a
Simple Mind. This will add a Sensor, Mind and Path
Manager to the game object, you should see these items
in the Unity Hierarchy window.


6
RAIN{one}
Beginners Guide
http://support.rivaltheory.com/
In addition to these components the RAINAgent component and
an AIKinematic Controller have been attached to the Player. You
can find these components in the Inspector window.
That’s it. For all intents and purposes your game-object is now
capable of interacting with the game-world in an intelligent
manner. Let’s get him to move.
Moving Your AI
Now that the game-object has an AIKinematic
Controller attached it is capable of intelligent
movement. RAIN{one} utilizes Waypoints
to determine the most efficient paths to use
during movement. The AIPlayer in our example
has been rigged with a Simple Mind but no
Waypoints have been set up in the scene yet.
Our goal here is to create a path straight down
the walkway to the edge of the map.
1. Open the Path Manager
Select the Player, then select the Path Manager from the
Hierarchy Window.
7
RAIN{one}
Beginners Guide
http://support.rivaltheory.com/
2. Add A Waypoint to the Scene
From the Inspector Window click “Create A New
Waypoint Collection”. This will group together all
of the Waypoints and associate them with Player.
Now, select “Add A Waypoint”. This will add a new
Waypoint to the scene and will position it directly in
front of your viewpoint. From there you can click and
drag your Waypoint to your desired position.
Note: If you are having trouble seeing the Waypoints
you can change the color of each one by clicking the Waypoint and then clicking the color bar in the Gizmo
Color field from the Inspector Window.
3. Add the rest of the Waypoints
Click the Waypoint you just dropped and move your viewpoint closer
to the area where you are going to add the new Waypoint. Click “Add
A Connected Waypoint” from the Inspector Window. This will add
a new Waypoint to the scene and will automatically connect it to the
original Waypoint. Our scene now has two connected Waypoints. You
can repeat this process until you reach the edge of the map.
The result should look similar to below, depending on how many
Waypoints you added and the direction of the path you created. The
Player, circled in the the picture below, now has a path to follow.
8
RAIN{one}
Beginners Guide
http://support.rivaltheory.com/
4. Drop the Waypoints to the Surface
Waypoint navigation is easier for the AI when the Waypoints are located directly on the walking surface. When
you are finished placing your Waypoints it is recommended that you drop the Waypoints to the surface. To
do this, first select the Path Manager of the Player from the Hiearchy Window and then click on the “Drop
Waypoints to Surface” button, located in the Inspector Window.
5. Add a Target Location
The Waypoints have been set up and dropped to the surface for easy navigation. Now we want to tell the Player
to move to a location near the Waypoints. There is a crateSmall object located just beyond the final Waypoint
in our path (in the final picture on the previous page this crate is located at the far right, the crate is also at
the center of the picture below). Select the crateSmall object. It should now be highlighted in the Hierarchy
window. Rename the object to something like crateSmall(moveTo), just so that it’s distinguished from the many
crateSmall objects in the Hierarchy.
Now, select the Path Manager attached to the Player in the Hierarchy. Find the “Move Target” component of
the Path Manager in the Inspector Window, change the setting from “NONE” to “TRANSFORM”. This will
open a “Target Object” component. Find the renamed crateSmall object in the Hierarchy, click and drag it to the
“Target Object” component. The result should look similar to the picture below, depending on what you named
the object. What you’ve just done is instructed the Player to move to the crateSmall object, without any code!
Now, go ahead and press Play and view the Scene as the game runs. The Player should move along the
Waypoint path you created, toward the crateSmall object. With that, you’ve successfully created your first
functional AI!
9
RAIN{one}
Beginners Guide
http://support.rivaltheory.com/
Sensing with your AI
Up to this point you have rigged your character with a Simple
Mind and created a path for it to move along. When you
added the Simple Mind a Sensor was automatically added to
the Player, an Expanding Bos Sensor in this case, allowing
it to sense. The next step is to actually make game-objects
detectable by your character.
You can make objects in the game-world detectable by
adding Aspects to them. You can add Aspects to any game-
object through the RAIN menu.
You can think of an Aspect as an attribute of the game-object.
For example, if you had a tree in your game world you
could add an Aspect to it that does nothing more than simply
identify the tree as a “tree”. The tree would then be detectable
by any game-object set up to sense it.
The next walk through will show you how to add an Aspec to a barrel in the AngryBots project. First, though, a
note about Raycasting.
Raycasting
At times the Sensor being used by the game-object may sense information it’s not supposed to. In the Angry
Bots project the Player now has an Expanding Box Sensor attached to him. As the Player moves next to walls or
other objects not meant to be seen through the Sensor may detect information that wasn’t meant to be detected.
For example, an enemy mech may be positioned on the opposite side of a closed door. As the Player approaches
the door the Sensor, because of its size, detects the enemy mech before the door even opens. RAIN{one} uses
Raycasting to prevent this type of behavior.
With the Sensor component for the object selected (in the Hierarchy Window), you can find the Raycasting
component in the Inspector Window. The component reads “Use Raycsat Test”. By default Raycasting is turned
on. You can turn off Raycasting via the checkbox.
Now, let’s begin adding Aspects to our scene.

10
RAIN{one}
Beginners Guide
http://support.rivaltheory.com/
1. Select the Game-Object you want to be detectable
Pick any object you want to be detectable. In this example we have selected a barrell located near the Player.


2. Add an Aspect through the RAIN Menu
Navigate to the RAIN menu and select Add Aspect --> Visual.
You will notice that there are six available Aspects with each
Aspect being associated with a Sensation: Visual, Tactile, Auditory,
Olfactory, Taste and Custom. The first five correspond to the five
human senses while the Custom Aspect will allow you to create an
Aspect associated with a custom Sensation.
The Sensation you select is important. Not all Sensors can detect
every Sensation automatically. For example, the default Expanding
Box Sensor is a visual Sensor. If you add an Aspect associated with
any Sensation other than Visual, the Expanding Box Sensor won’t be
able to detect it without some simple modification (see the “Sensors”
section in the RAIN{one} User Manual for more details)
After you have added an Aspect you will find one or more new
components added to the object in the Inspector Window.
The most important new component is the “Entity”. The Entity is
what the Sensor will look for when it is sensing the world. When
your character’s sensor detects that the game-object has an Entity
it will begin sensing the information about the object. Without the
Entity component the object will go un-sensed. You will also see a
“Decoration” component in the Inspector Window. This component is
associated with the Entity and encompasses information about the new Aspect.
11
RAIN{one}
Beginners Guide
http://support.rivaltheory.com/
3. Add an Aspect Name
The Aspect has no value to your AI until you give
it a name. This is what defines the property or
characteristic you are associating with the Sensation of
the Aspect. In this case the Aspect was named “Barrel”.
When our character moves through the scene and
comes upon this game-object it will detect that it is a
“Barrel” and respond (if necessary) to this information.
Behavior Trees
Behavior Trees are one of the primary features of RAIN{one}. Behavior Trees allow for more complex, task-
oriented decision making. In addition, they are easily constructed, modified and re-used. RAIN{one} makes the
creation of Behavior Trees easy via a point and click Behavior Tree Editor which you can find under the RAIN
--> Behavior menu. Before we get started creating a Behavior Tree, let’s take a look at how to rig an AI with a
Behavior Tree Mind.
1. Select the Game Object you want to rig with AI
Click on the object in the game-scene or click on the name of the object in the Hierarchy Window. For this walk
through we are going to use the Player from the Angry Bots demo once again.
2. Add a Behavior Tree Mind
Navigate to the RAIN menu and select Create AI --> with a
Behavior Tree Mind. Similar to when you added a Simple
Mind, you will see the same new components added in both the
Hierarchy Window and the Inspector Window.
3. Generate an Activation Manager
An Activation Manager links the Behavior Tree to the Behavior
Tree Mind your AI has been rigged with. In the Hierarchy
Window click the Mind component of your AI. From the
Inspector Window, click “Generate Activation Manager”. This will generate the script needed to link your
Behavior Tree with the Behavior Tree Mind of your AI. You will need to drag this Activation Manager from the
Project Window to your Behavior Tree Mind Component. In your Project Window find the “AI_Manager_1”
file under AI --> Scripts. Drag the AI_Manager_1 file to the space beneath the “Generate Empty Action Script”
button. Then, click and drag the “AI_Manager_1 (Script)” component name to the “Activation Manager” field
of the Behavior Tree Mind component. The result should look exactly like the picture above.
12
RAIN{one}
Beginners Guide
http://support.rivaltheory.com/
Creating a Behavior Tree
The easiest way to understand a Behavior Tree is to create one, the basic components (nodes) that make up a
Behavior Tree will be explained along the way.
1. Open the Behavior Tree Editor
Navigate to the RAIN menu and select Behavior --> Behavior
Tree Editor.
2. Create a new Behavior Tree
From the drop down menu on the right side of the Behavior
Tree Editor select “Create New Behavior Tree” and choose a
name for this new Behavior Tree.

3. Begin Adding Nodes to your Tree
After you have selected a name you can begin creating
the logic of the tree. Notice that two nodes have already
been created, a yellow “BT” node and a red “SEQ” node.
The yellow BT node is known as the root of the tree. The root of the tree has no attributes assigned to it as it
simply serves as the root for all of the other nodes. The name given to the root node, “EnemyMech” in this case,
is the name you will use to link this tree to any AI you want to use it.
The tree is now ready to have logic added to it. First, let’s look at the different nodes available for use.
13
RAIN{one}
Beginners Guide
http://support.rivaltheory.com/
Nodes
RAIN{one} features a number of nodes to use in your Behavior Tree logic. Six of these nodes are used to apply
different types of logic to your tree while the final five nodes can be used to supplement or add some kind of
action to your logic.
- Sequencer Node
Now that you have created your Behavior Tree you are seeing a red “SEQ” node underneath the root BT node.
SEQ stands for Sequencer. The Sequencer node defines a task that is composed of a set of smaller tasks that
should be carried out in sequence. For example, the task may be “Go to the car” and the smaller tasks attached
to this may be “Stand up”, “Get keys” and “Walk to car”, which would all be executed in sequence until the
original task is completed.
- Selector Node
The Selector node defines a task based on choices and is useful for choosing courses of action based on
conditions. If the task is still “Go to the car”, you could use a Selector node to create behavior based on the
location of the car. If the car is outside your logic may included grabbing a jacket and going out of the front
door, whereas if the car is in the garage the logic would change and the AI would use the door to the garage
instead of going out the front door.
- Condition Node
The Condition node isn’t a task at all, instead, the condition defines something we want to check for validity.
In the above examples the location of the car would be a condition, since varying behavior exists based on this
information.
- Action Node
The Action node is where the logic of the task ends and some action is taken by your AI. This is where your
Behavior Tree logic will finally meet the code of the game.
- Iterator and
Parallel Nodes
These are the last two nodes available for use. These nodes are explained in the full RAIN{one} User Manual
and are beyond the scope of this Beginners Guide.
14
RAIN{one}
Beginners Guide
http://support.rivaltheory.com/
Primitive Nodes
These nodes allow you to add movement, actions and additional information to your logic without the use of
code.
- Move
The Move node will allow you to easily make an AI move to a specific location or even to a location that varies
based on the state of the game-world. It will also allow you to assign a specific location or other character for
your AI to focus on while it moves. Animations can also be easily attached.
- Animate
The Animate node will allow you to easily attach an animation to your AI.
- Audio
You can select a sound to be played with the Audio node.
- Detect
With the Detect node you can trigger the AI’s Sensor to begin looking for specific Aspects in the game-world.
You can then store this information in a variable for use in other AI functions.
- Assign
The Assign node will allow you to define extra information to be used in your logic.
15
RAIN{one}
Beginners Guide
http://support.rivaltheory.com/
Adding Behavior Tree Logic
Now you are ready to begin adding logic to your tree. We will use
the tree we created earlier. By default, a Sequencer node has been
added and is called “root”. First let’s see how you add and remove
nodes from the Behavior Tree. Let’s change the original Sequencer
node to a Selector node and re-name it.
1. Delete the Sequencer Node
Right click the line that the SEQ node is located on and select
“Delete”. This will remove the Sequencer node, the only node
remaining should be the yellow BT root node.
2. Add a Selector Node
Right click on the yellow BT node and select Create --> Selector.
This will add a blue Selector node underneath the BT node. Re
-
name the Selector node to something that describes the task you are
about to define. You can rename a node by clicking on it and then
changing the “Name” field on the right side of the Behavior Tree
Editor screen.
In this case the Selector node was renamed to “Enemy Behavior”.
3. Add another Node
Right click the Enemy Behavior node and select Create
--> Sequencer. If you don’t see the Sequencer node it may
simply be collapsed underneath the Enemy Behavior node.
If this is the case you will see a small arrow underneath the “SEL” node, click the arrow to expand and view the
new Sequencer node.
Just as before, you will want to rename the new Sequencer node to something that describes the task. In this
case the node is named “Patrol”.
16
RAIN{one}
Beginners Guide
http://support.rivaltheory.com/
Add Nodes to Complete Your Behavior Tree
You can continue adding nodes until you have a complete
Behavior Tree.
Adding your Behavior Tree to your AI
Now you have a complete Behavior Tree that you want to attach to your rigged AI. This is as easy as typing in
the name of the Behavior Tree you created.
1. Select the game-object rigged with AI
Click the game-object or select it from the Hierarchy Window.
2. Select the Mind of the AI
Click on the Mind in the Hierarchy Window.
3. Type in the Name of the Behavior Tree
In the Inspector Window find the Behavior Tree Mind component. Click the area to the right of the Behavior
Tree Filename field and type in the name of the Behavior Tree you created. This is the same as the name
given to the yellow BT node of the tree. Remember, the names are case sensitive. In this case if you typed in
Enemymech instead of EnemyMech, RAIN{one} would not attach the correct tree.
4. Type in the Name of the Root node.
While still at the same screen find the Root Name field, this
should be located directly underneath the Behavior Tree
Filename field. Type in the name of the root node of your
tree. In our example our root node was a Selector node named
“Enemy Behavior”. Again, names are case sensitive.
Once you have completed this step your AI is attached to the Behavior Tree you created.
17
RAIN{one}
Beginners Guide
http://support.rivaltheory.com/
What’s Next?
Now that you have a feel for how RAIN{one} works you can continue creating AI’s and making your game-
world interactive. Now is also a good time to read through the RAIN{one} User Manual, where each one of the
topics discussed in this Beginners Guide is expanded on. The User Manual also contains code-examples and
topics not yet covered in the Beginners Guide. Also, if you haven’t yet, it would be a good idea to take a look at
the API documentation at
http://support.rivaltheory.com/documentation/api-documentation
.
Good luck and have fun!