Target Boxes

The UVC kits come with a comprehensive target box system that enables you to show different target boxes for different target types, as well as information such as distance, target health, weapon lock state, and lead target boxes.

Setup

  1. Add a HUD Target Boxes component anywhere on your vehicle.

  2. Open the inspector and add the Tracker from the vehicle's root transform to the Trackers list

  3. Add a target box prefab to the Default Target Box field. We'll create target boxes below but for now you can use the Target Box Generic prefab provided in the demos.

  4. Create a canvas for displaying the target box UI (if you haven't already) and drag it into the Canvas field in the inspector of the HUD Target Boxes component

Now when you play the game, target boxes will appear over targets in the scene.

Off Screen Arrows Mode

In vehicle combat games, there are two main ways that arrows pointing at off-screen targets are displayed: on the edge of the screen, or in a circle around the screen center.

With the target box system you can easily switch between both of these with the Target Box Off Screen Mode in the inspector of the HUD Target Boxes component.

World Space vs Screen Space

If you are creating a VR game, or you would like to have the perspective distortion effect of the camera on the UI, you can set up the target boxes in world space simply by setting the Render Mode of the canvas that the target boxes are displayed under to World Space.

There are several settings in the inspector of the HUD Target Boxes component that enable you to customize the world space UI, such as the distance from the camera that the target boxes are rendered, as well as how far away from the screen borders the off screen arrows are shown (since in VR the screen borders are not always visible).

Creating Target Boxes

Creating A Target Box

To create a new target box:

  1. Create a new empty game object with a Rect Transform component

  2. Add a HUD Target Box component

  3. Add a UI Color Manager component and drag it into the Target Box Color Manager field in the inspector of the HUD Target Box component

  4. Create the visual style of the target box and add all the images/renderers to the UI Color Manager inspector.

  5. Drag the target box into the Project tab to create a prefab

  6. Open the inspector of any HUD Target Boxes component and drag the prefab into the Default Target Box field, or add an override for a specific target type

Refer to the Target Box Generic prefab for an example.

Locking UI

You can add any number of locking animations to a target box.

  1. Add a HUD Target Box_Locks Controller component to the target box

  2. Set it as the Locks Controller in the inspector of the HUD Target Box component

  3. For each lock animation you want to add, add a HUD Target Box_Lock Controller component somewhere on the target box and add it to the Lock Boxes list in the inspector of the HUD Target Box_Locks Controller component

  4. Create the lock box and customize the settings of the HUD Target Box_Lock Controller component

Now, for each target locker on the vehicle (e.g. a missile weapon) that has locked onto a target, a lead target box will be shown.

Lead Target UI

You can add any number of lead target boxes to a target box.

  1. Add a HUD Target Box_Lead Target Boxes Controller component to the target box

  2. Set it as the Lead Target Boxes Controller in the inspector of the HUD Target Box component

  3. For each lead target box you want to add, add a HUD Target Box_Lead Target Box Controller component somewhere on the target box and add it to the Lead Target Boxes list in the inspector of the HUD Target Box_Lead Target Boxes Controller component

  4. Create the lead target box and line, and customize the settings of the HUD Target Box_Lead Target Box Controller component

  5. Go back to the HUD Target Boxes component, and make sure the Lead Target Info field is set (usually this will be the Weapons component on the vehicle's root transform, but it can be any component that implements the ILeadTargetInfo interface).

Now, for each lead target calculation on the vehicle's Weapons component (which corresponds to a gun weapon), a lead target box will be shown

Last updated