Game Development Reference
In-Depth Information
ai.WorkingMemory.SetItem<GameObject>("gold",
null);
Object.Destroy(gold);
}
public override ActionResult Execute(AI ai)
{
return ActionResult.SUCCESS;
}
public override void Stop(AI ai)
{
base.Stop(ai);
}
}
The important code here is in the Start method. We got the gold game object that
was sensed from the memory and then erased it from memory by setting the gold
value to null . Then, we destroyed the gold object, so it won't be sensed anymore.
If you run the code now, the ship will follow the path, pick up gold when it sees it, and
then go back to the path.
Next, try adding several more gold prefabs to the scene and run the demo, as shown
in the following image:
Now in the demo, the ship will go and collect all the different gold pieces it sees and
then return to the path.
Search WWH ::




Custom Search