Skip to content

Sight

The Sight is one of the most useful sensors of the Perception component and it allows to check whether there's a line of sight between the agent and another tracked object.

Settings

Perception Sight Settings

The Update field determines whether the vision cone is updated every frame, at a specified interval, or manually done (using a custom Instruction or a script). By default we recommend leaving it to Every Frame unless there are performance reasons.

The Detection Speed determines how fast the Awareness value increases when the tracked object is in its line of sight.

Maximum Detection Speed

Note that it is possible that the detection speed during runtime is slower than Detection Speed. This is because this field determines the maximum speed at which the Perception component will increase awareness, but there might be factors, such as low light and distance, that dampens the detection speed.

The Layer Mask is a physics mask used during the ray-cast phase and allows to determine what is an obstacle between the Perception component and the tracked object, and what is not.

The Optics field references a humanoid or generic bone from the game object with the Perception component, and it's the position where the eye should be. Characters will always ray-cast to the center of the tracked game object. When tracking characters, such as the player, the position is also the hips.

Eyes on the hips

Notice that by default, characters see the world from their hips. This is because it's easier to hide from enemies when their eyes are at hip-level.

The Use Luminance checkbox determines whether light conditions affect the detection speed or not. Unless you're making a stealth game, we recommend leaving the checkbox unticked, since it slightly increases performance.

If this field is ticked, two new fields will appear below:

  • Dim Threshold: The minimum amount of luminance required for the Perception component to barely see a tracked object.
  • Lit Threshold: The maximum amount of luminance required for the Perception to detect tracked objects at full speed.

Example of Dim and Lit thresholds

Let's say we have a Perception component with:

  • Dim Threshold = 0.2
  • Lit Threshold = 0.5

This means that any tracked object will require to be illuminated with an intensity of at least 0.2 in order for this Perception component to detect it. However the detection speed will be very slow, and will gradually increase until it's illuminated with an intensity of 0.5. Higher light intensities won't further increase detection speed.

Night Vision

Thanks to the Dim and Lit thresholds it's very easy to make enemies wear night vision goggles. You can simply turn the Dim Threshold all the way down to zero and Lit Threshold to something very small, like 0.1. This should be enough to detect the player in poor light conditions.

For more information about setting up lights when tracking objects, see the Luminance page.

Primary & Peripheral

At the bottom of the Sight sensor has two expandable boxes called Primary and Peripheral which represent the primary and peripheral vision cone.

The Primary cone is where the Perception can fully detect tracked objects. However if the tracked object is inside the Peripheral cone the speed at which it is detect is reduced by proportionally.

This means that the further away it is from the Primary cone, the slower the detection speed will be.

Perception Primary and Peripheral Vision

Both boxes contain identical fields:

  • Angle: The angle extension in front of the Perception component.
  • Radius: How far the vision cone extends.
  • Height: The vertical size of the vision cone.

Perception Primary and Peripheral Cone

You can see in real-time a gizmo representing the Primary and Peripheral vision cones in the scene view.

Peripheral extends Primary

The Peripheral values extend the Primary ones. That means that if the Primary Radius is 5 and Peripheral Radius is 2, peripheral's radius is actually 5 + 2 = 7.