# 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.

![](/files/x7cAFGOK8bBXESs6UXzN)

## 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.

![](/files/F7cBmMp6y4P5T5ZKUkXL)

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

![](/files/PBiQtdZlIVqRNoYNbzyB)

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

![](/files/ac5g5H3awDIf4Yq4sVxg)

* 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://malbersanimations.gitbook.io/animal-controller/utilities/lock-on-target.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
