# Lock On Target

## Overview

The Lock on Target Component uses a GameObject Runtime Set to Find the closest gameObject on the Set.

These are used by the Lock On Target component to Lock on a Target.

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FoPmXjffnBTegFB4Zy0VW%2Fimage.png?alt=media\&token=2f5e0767-900c-40bb-a7c7-391107b1bfa8)

## How to Use it

{% embed url="<https://streamable.com/rso24f>" %}

Once you have your Animal Set with the Aim and/or Look At Component set.

* Find the Prefab Lock On Target on the Project Window and add it to your character. You can set it as child gameobject of your character.

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FfQ7BMy3Y1iHIdc5paPvO%2FUnity_Zy8doLxCZm.gif?alt=media\&token=1c2d03ce-f8e1-484b-bd34-b829e7696833)

This prefab includes the Lock On Component already set. It also has a Trigger Proxy with an Sphere Trigger to collect all possible Targets the character may encounter.&#x20;

Set your Layers on your Trigger Proxy and the Tags you are going to use for finding possible lock on targets

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2Fvxmr4ANZ3Q727naL3P4q%2Fimage.png?alt=media\&token=810c4650-1aa5-44b4-a854-c3d22a4c9177)

* On your scene add also the Cinemachine virtual camera \<CM Lock On Target>

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FT5LfIjQkuCv7OIGYRgTT%2FUnity_UqmLAnNVJ3.gif?alt=media\&token=cfdd8436-3970-45b4-ae85-22ead9937baf)

* Create the Input to connect the Lock On Target to the middle mouse button click. In AC 1.3.1+ you can create the Input automatically on the Input Context Menu.

## Parameters

### Aim

Reference for the Aiming Component. This is required

### Targets

Reference for the Runtime Game Object set where all the possible Lock On Targets will be stored.

## Events

### On Target Changed

Is Invoked when a new Target is assigned to Lock On. This will send the transform chosen to the Camera Event and it will also stored in a Transform Hook.

### **On Locking Target**

Is Invoked when the Lock On feature changes on and off. Useful if you want to activate the Strafe Mode on the Animal Controller.
