Target Selectors

Creating Target Selectors

To add a target selector to a vehicle:

  1. Add a Tracker Target Selector component anywhere on the vehicle

  2. Open the inspector and set the Tracker field to the Tracker you added to the vehicle above.

  3. If this target selector is the one used by the weapons, go to the Weapons component on the vehicle and set the Weapons Target Selector to the target selector you just added

  4. Customize the settings in the inspector

Target Selection Input

To set up target selection controls:

  1. Add a new game object under the Player in your scene

  2. Add a PlayerInput_InputSystem_RadarControls component

Now, when the player gets in the vehicle, the targeting controls will work on the target selector defined in the vehicle's Weapons component.

The targeting controls are set up using Unity's Input System. Open the General Input input asset in the Project tab by double clicking it, navigate to the Targeting Controls section, and you'll be able to modify the input bindings there.

Currently, you can choose Next, Previous, Nearest and Front targets. Here are some code snippets you can use if you wish to control the target selector:

// Select the next target
myTargetSelector.Cycle(true);

// Select the previous target
myTargetSelector.Cycle(false);

// Select the nearest target
myTargetSelector.SelectNearest();

// Select the target in front
myTargetSelector.SelectFront();

// Select a specified target
myTargetSelector.Select(myTarget);

Cursor Target Selection

To enable cursor target selection on your vehicle:

  1. Make sure your vehicle has an Aim Controller component on it

  2. Check the Aim Target Selection Enabled checkbox in the inspector

The Aim Controller is discussed in more depth here.

Target Selection For AI

By default, in the demos provided in the kit, the AI uses the target that is selected by the Target Selector that has been assigned to the Weapon component on a vehicle as its combat target.

Last updated