Game Development Reference
In-Depth Information
move there. To pick a random spot in the level, create a new Custom Action option
with a new script called ChooseRandomSpot . Set the following code for it:
The Start method uses our static Ground method to find a random position in
the level and sets it to the moveTarget variable in the AI's memory. Next, add a
move node to go to the moveTarget variable. If you need a review of how to set up
these nodes, check Chapter 6 , Sensors and Activities . The behavior tree for the ship
should look like the following screenshot:
Change the ship to a prefab and add a few ships to the level. Now if you run the
game, your ships will wander around, but if they see gold, they will race to pick it up
and the first one there collects it.
Using RAIN's motor directly
However, if you run the game now, you'll see a problem. As expected, the ship will
look for gold, and if it doesn't see any, it will pick a random position on the level and
move toward it. If it sees gold along the way, it doesn't stop to pick it up; it keeps
moving to its target location.
Search WWH ::




Custom Search