Game Development Reference
In-Depth Information
The chase and attack demo
In the first demo, we will build an enemy ship that senses for the player, and if it sees
the player, it starts moving toward it and then attacks it. A simple version of this would
be to have the enemy wander with a visual sensor to detect the player, and if it sees
the player, the enemy will move toward it and attack it. This would work but it really
wouldn't be any different from the demo from Chapter 7 , Adaptation , where the ship
had to search for and collect gold. To make it a little different, we'll use a two-sensor
approach. We will have one larger sensor on the enemy that detects the player, and
if the enemy senses the player aspect, it will start chasing the player. Then, there is
a second smaller sensor that attacks the player, that is, if it senses the player, then
the enemy stops chasing and it instead attacks. This gives the effect of chasing the
player but when the enemy gets closer, it stops and starts attacking, instead of just
chasing and attacking at the same time.
To begin setting these up, go to the Perception tab on the enemy AI rig (the little eye
icon tab) and add a visual sensor called ChaseSensor . This should be pretty large
and cover most of the scene. Then, add a second visual sensor and call it Attack-
Sensor . Make this one about a third the size of ChaseSensor . The setup should
look something like the following screenshot:
Search WWH ::




Custom Search