Target Scanner

Проверено с версией:: 2018.1


Сложность: Базовая

The Target Scanner is a simple class that enemies use to detect whether they can see the player.


  • height Offset: The height at which the "eyes" of the character is using the scanner. When set to 0, the raycast has an unobstructed line of sight at the start of the object pivot. The height Offset is displayed as a yellow wire sphere in the Scene view.

  • detection Radius: The radius around the object in which the scanner can detect the player. The detection Radius is displayed as a blue circle in the Scene view.

  • detection Angle: The angle from the object facing the player in which the scanner can detect the player. For example, a value of 90 gives the scanner is a narrow view cone in front of the player. The blue circle arc in the Scene view represents the zone that corresponds to that angle with the above detection radius value.

  • max Height Difference: The maximum difference in height between the object pivot and the player pivot where the scanner can detect the player. This is useful if you don't want enemies on planes above or under the player (but still in direct line of sight) to start running after the player.

  • viewBlockerLayerMask: A Layer mask of what is considered to be "blocking" the view of the scanner. The line of sight raycast will be done only against objects in those layers.


Use the Target Scanner as a member of the Monobehaviour, and call Detect when you want to do a Detection check. It will return the PlayerController if it's visible, null otherwise.

See ChomperBehaviour.cs function FindTarget for an example.