Game Development Reference
In-Depth Information
Note
The whole quotes thing in RAIN can be confusing: why some fields need quotes
and others don't. This is planned to be improved in future versions of RAIN, but
for now for Expressions (fields with the little e symbol) a value with quotes means
the name of an object and without means the value of a variable. So in our case,
"Visual Sensor"
and
"Gold"
were both in quotes as they were referring to ob-
jects by name, but
gold
is an actual variable we store data in, so it doesn't have
quotes.
Your setup should look like the following screenshot:
In the preceding screenshot, you can see the behavior tree with the
detect
node.
Now if you run the game, the gold will be detected, but the ship still doesn't move
to it yet. To do this, we will use a selector node similar to the original behavior tree
demo. Place a
selector
node under root and create a
constraint
node as a child
with a
Constraint
value of
gold == null
. Then, move the original patrol node to be a
child of the constraint. The setup should look the following screenshot:
The preceding screenshot shows a detection behavior tree with a
constraint
node.
Now if you run the demo, when the ship sees the gold, the gold value will not be null
and it will stop moving. However, instead of stopping, we want it to move over to the