Target Selectors

Setup

To add a target selector to a vehicle that can select a target from the targets currently being tracked by a Tracker:

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

  2. Open the inspector and set the Tracker field to the Tracker that's on the vehicle.

  3. If this target selector is the one used by the weapons (for target locking, target leading, etc), 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 Asset 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, Front, and Under Cursor 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.

Subsystem Target Selection

There are two ways you can select subsystems with a target selector.

First, you can go to the Tracker Target Selector component and check Select Highest Depth Child. Now, when the target selector cycles through targets, if its comes upon a target that has subsystems (child trackables) it will select the first subsystem as the selected target, and cycle through all the subsystems before going to the next target.

Alternatively, you can:

  1. Add a Subsystem Target Selector component.

  2. Go to the inspector and set the Parent Target Selector to the Tracker Target Selector you added earlier.

Now, when the Tracker Target Selector selects a target which has subsystems, the Subsystem Target Selector will be able to cycle through its subsystems.

Target Selection For AI

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

Last updated