Targeter Component

Included in the Combat Examples module is a prefab called PlayerTargeter that demonstrates how to use the Targeter component. The Sphere Collider attached to the same game object (as depicted in the inspector screenshot below) is required. Note that the range of the Targeter is dictated by the Radius property of this collider. The PlayerTargeter prefab should be nested under the Game Creator Player object.

Targeter component

Auto Aim At Target#

Automatically aiming at a target can be disabled with the Auto Aim At Target option - the character will still be locked on to it, but will not fix their weapon on it while aiming. This may be desirable for some games.

Target Visibility#

New in 0.4.0

The component's target visibility options allow for target selection to be limited by what the camera can see.

Only Target Visible To Camera#

If enabled, only targets possibly visible to the camera (i.e. in its view frustum) are targetable.

Only Target Non-Occluded#

If enabled, targets hidden behind objects are not targetable.

Note that this option is turned off by default because the player and targetables need to be on dedicated layers which requires manual configuration.

Layers To Ignore For Visibility Occlusion#

The layers to ignore when determining target visibility when Only Target Non-Occluded is enabled.

Typically, there should be two layers:

  • A "Targetable" layer that contains all targetable objects.
  • A "Player" layer that contains the player.

User Input#

The User Input section of the Targeter component allows the keys that control target locking and switching to be customized.