Game Development Reference
In-Depth Information
You can see the ships wandering and chasing gold in the preceding screenshot.
Adding large game events
As the last step of this demo, let's have a giant bomb go off in the scene and then
have all of our AI stop to simulate having them all destroyed. To start, create a large
red sphere to represent the bomb and turn it into a prefab. We will have the AI char-
acters react to this bomb in the standard way by adding a RAIN Entity component
to it and a visual aspect and have visual sensors on the ships detect it. But to show
we can access the AI systems directly, let's have the bomb go off using the Ground
class:
Here, we added a bomb transform to the script, so drag the bomb prefab in the Unity
prefab over to it. There is also a field for a countdown that when it goes to 0, the
bomb goes off and is instantiated into the scene. At this point, we grab all the AIs in
the scene and send them a message, in this case, to disable it. We could have made
this more complex than a simple disabling; this just shows us that we can have our
game AI react to game events from anywhere. If you run the demo now, the ships
stop when the bomb goes off, as shown in the following screenshot:
Search WWH ::




Custom Search