Next: , Previous: , Up: AI   [Contents][Index]


2.7 Targeting Sensor

Component: TargetingSensor

This component should be attached to a trigger that is parented to an AI. It provides target information to other AI components. To use most effectively, we recommend creating 4 collision layers (at least), one each for friendlies and enemies, and one each for friendly and enemy sensors. Then in the Physics Manager (Edit -> Project Settings -> Physics) make it so that the enemy sensor collides only with friendlies and vice versa for friendly sensor. This speeds up target detection, allowing more AI to be active at once. To further refine target lists, assign some target tags because anything not in that list is completely ignored.

Field of TargetingSensor: string[] targetTags

What tags are we looking for while targeting? Any Game Object with one of these tags that is found will be passed as a target to the ’Message Receiver’ defined below.

Target Settings

Field of TargetingSensor: bool targetRoot

Should we target the root transform of the object detected, or the object itself? Useful if colliders are parented to agents instead of being part of their root object.

Default value: false

Line Of Sight

Field of TargetingSensor: bool checkLOS

Should we check line of sight between the message receiver and the target? This requires a raycast, which queries the physics engine and can be expensive.

Default value: false

Field of TargetingSensor: Vector3 rayOriginOffset

How much should we offset the ray origin from the origin of the message receiver?

Default value: Vector3.zero

Field of TargetingSensor: Vector3 rayTargetOffset

How much should we offset the target point of the ray against the target we’re checking for LOS?

Default value: Vector3.zero

Field of TargetingSensor: LayerMask obstructionMask

What physics layers can obstruct the view of this AI? This should NOT include the target!

Field of TargetingSensor: bool chaseToLOS

Should we try to get into line of sight if we don’t have it?

Default value: false

Field of TargetingSensor: bool debug

WARNING! SLOW OPERATION! Should we output useful information to the console?

Default value: false

Field of TargetingSensor: string[] targetTags

What tags are we looking for while targeting? Any Game Object with one of these tags that is found will be passed as a target to the ’Message Receiver’ defined below.

Target Settings

Field of TargetingSensor: bool targetRoot

Should we target the root transform of the object detected, or the object itself? Useful if colliders are parented to agents instead of being part of their root object.

Default value: false

Line Of Sight

Field of TargetingSensor: bool checkLOS

Should we check line of sight between the message receiver and the target? This requires a raycast, which queries the physics engine and can be expensive.

Default value: false

Field of TargetingSensor: Vector3 rayOriginOffset

How much should we offset the ray origin from the origin of the message receiver?

Default value: Vector3.zero

Field of TargetingSensor: Vector3 rayTargetOffset

How much should we offset the target point of the ray against the target we’re checking for LOS?

Default value: Vector3.zero

Field of TargetingSensor: LayerMask obstructionMask

What physics layers can obstruct the view of this AI? This should NOT include the target!

Field of TargetingSensor: bool chaseToLOS

Should we try to get into line of sight if we don’t have it?

Default value: false

Field of TargetingSensor: bool debug

WARNING! SLOW OPERATION! Should we output useful information to the console?

Default value: false


Next: , Previous: , Up: AI   [Contents][Index]