Skip to content

Targeter

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

Aiming#

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.

Camera Motor#

If set, the camera will switch to this alternative camera motor while aiming at a target.

Targeting#

Enable#

If enabled, targeting will be enabled when the scene loads.

Acquire Initial Target#

If enabled, the closest target will be automatically set if one is available.

This is useful to disable for mouse targeting

Continuing To Be Targeted Event Period (in seconds)#

The number of seconds between triggering the Targetable's "Continuing To Focus" event.

Camera Motor#

If set, the camera will switch to this alternative camera motor while targeting A target.

Type#

This setting specifies the type of targeting strategy that is used to select and interact with targets. Each mode has a separate set of sub properties to configure the type-specific targeting.

Proximity#

Proximity targeting has a variety of target visibility options and user input control options. They allow for target selection to be limited by what the camera can see and/or what the player model can "see" from its perspective.

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.

Mouse#

Mouse targeting has no type-specific settings.

Aim Assist#

Aim assist targeting requires the Shooter module. When a player aims at a target with a Shooter weapon, the Targeter locks onto the target. Moving the mouse/joystick/trackpad disengages the target lock.

  • Mouse
  • Aim Assist - Requires the shooter module.
Deselect Target Input Threshold#

The amount of horizontal movement it takes to deselect an aim assist target. This property makes the lock more "sticky."

Acquire Target Delay (Seconds)#

The number of seconds to wait before a new target can be acquired. A small delay is useful if targets are dense, but normally this setting should not be adjusted.