Game Development Reference
In-Depth Information
The preceding screenshot shows our enemy setup with two sensors: one will be
used to chase and the smaller one will be used to attack.
Note
Using multiple sensors of the same type is a powerful tool to have AI characters
react to things differently based on how far away they are.
Now we have our sensor, we can work on the behavior tree for the enemy. Select
the Mind tab of the enemy AI rig and open the behavior editor. Create a new be-
havior tree called ChaseAndAttack . The enemy will detect and chase or attack the
player at the same time, so right-click on the root node and change its type to Par-
allel . Then, add two detect nodes, one for the chase sensor and one for the attack
sensor. For the chase detect node, set Sensor to "ChaseSensor" , Aspect to "play-
er" , and the form variable to playerChase (remember to watch out for the quotes).
For the attack sensor, set Sensor to "AttackSensor" , Aspect also to "player" , and
the form variable to playerAttack . Then, add a constraint node, which will go off
if either of the sensors has found something, so set its constraint to playerChase !=
Search WWH ::




Custom Search