Game Development Reference
In-Depth Information
gold; so, add another constraint node with the
Expressiongold != null
value and a
move
node below it that has a
Move Target
value of
gold
. Here is how the behavior
tree with the
detect
node settings will look:
If you run the demo now, the ship will move to the gold when it sees it. However, let's
change this so that the ship goes back to patrolling after the pickup. Make sure that
both root and selector nodes are set to
Forever
for their
Repeat
type. Then, create
move node for the gold. Create a new class for the custom action and call it
Pick-
UpGold
. Set its code to this:
using UnityEngine;
using RAIN.Core;
using RAIN.Action;
[RAINAction]
public class PickUpGold : RAINAction
{
public PickUpGold()
{
actionName = "PickUpGold";
}
public override void Start(AI ai)
{
base.Start(ai);
GameObject gold =
ai.WorkingMemory.GetItem<GameObject>("gold");