AI, Detectors & Emitters: Why you see me, why you don’t!

Debris emitter feature

AI Creature Perception using Detection and Emitters

Good day, subscribers! Another week in the books. We’re diving deeper and deeper into Debris’ mechanics, specifically AI (artificial intelligence). A lot of the logic in Debris is triggered dynamically based on the perceptions of the creatures in the world. It’s important to track not only what each creature can detect, but what the player can detect as well. Our AI system consists of emitters (eg. lights), detectors (eg. eyes) and a point of interest manager that filters results based on what the creature cares about. Here are some examples:

AI Detectors Emitters rig

The large circle represents the vision range of the flashlight fish (detector). The small circle represents the body of the fish and determines whether it is visible to other creatures (emitter). The cone is the volumetric light (like sunbeams or a flashlight in fog) that can be detected by other creatures (emitter).

There are a number of situations we have to account for to determine if a detector has direct or indirect vision of an emitter. This can be shown using elegant diagrams, like so:

Player Direct Detection

Player AI Detector Emitter

The light detector contains the light emitter and the raycast to the target does not hit any obstacles. The player knows all the information about the target.

No Player Detection

No Player AI Detector Emitter

In this case, the light detector contains the light emitter but the raycast to the target hits an obstacle. No information is given to the player.

Player Indirect Detection

AI Indirect Detection

Indirect detection is much trickier, as we need to determine line-of-sight to a volume. Both detector (player vision) and emitter (volumetric light) are represented by colliders that pass through geometry, so we need to be able to figure out if the light is actually visible.

Looking at the diagram above, since the raycast from the player to the target fails, we know that there is no direct detection. Then, we raycast again directly forward, stepping along that ray and casting towards the target. If these raycasts fail, that section of the volumetric light is blocked by geometry. If any of the raycasts succeed, we know we can see the light. BUT, we don’t know what creature is emitting it. How subtle!

AI Debris Emitter POV

To make sure the AI can retrieve information about its environment, we’ve added this emitter/detector system on every creature, including the player. The popups above each creature helps us understand what they are sensing while debugging.

We hope this was an interesting read, please leave any questions or comments below. We’d love to hear from you.

Sign up for updates

Leave a Reply

Your email address will not be published. Required fields are marked *