Game Development Reference
In-Depth Information
Chapter 6. Sensors and Activities
In the previous chapters on pathfinding and behavior trees, we had AI characters
moving through our AI environments and changing states, but they didn't really react
to anything. They knew about the navigation mesh and different points in the scene,
but there was no way for them to sense different objects in the game and react to
them. This chapter changes that; we will look at how to tag objects in the game so
that our characters can sense and react to them.
In this chapter, you will learn about:
• Sensors and tagging game objects so that they can be sensed
• AI characters that use sensors in RAIN
• Advanced configuration of sensors in RAIN
• Having AI characters react to different objects and perform different activities
once they are sensed
An overview of sensing
A part of having good game AI is having the AI characters react to other parts of the
game in a realistic way. For example, let's say you have an AI character in a scene
searching for something, such as the player to attack them or items to collect (as in
the demo in this chapter). We could have a simple proximity check, for example, if
the enemy is 10 units from the player, it starts attacking. However, what if the enemy
wasn't looking in the direction of the player and wouldn't be able to see or hear the
player in real life? Having the enemy attack then is very unrealistic. We need to be
able to set up more realistic and configurable sensors for our AI.
To set up senses for our characters, we will use RAIN's senses system. You might
assume that we will use standard methods to query a scene in Unity, such as per-
forming picking through Unity's ray casting methods. This works for simple cases,
but RAIN has several advanced features to configure sensors for more realism. The
senses RAIN supports are seeing and hearing. They are defined as volumes attached
to an object, and the AI might be able to sense objects only inside the volume. Not
everything inthevolumecanbesensedbecausetheremightbeadditional restrictions
such as not being able to see through walls. A visualization illustrates this volume in
Search WWH ::




Custom Search