---
description: 1.4.2.d+
---

# Aim

## Overview

The Aim Component is used to cast a ray from the Aim Origin gameobject to the center of the camera or an assigned Target.&#x20;

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FM049F02V2OqjuobBPJWp%2Fimage.png?alt=media&#x26;token=f7e49b21-d4d1-4dc4-b519-bbe67865979e" alt=""><figcaption></figcaption></figure>

It is commonly used to Aim Weapons, do a Head Look At, or for the Strafing logic.

## Requirements

* This component needs to have an Aim Origin reference.&#x20;

## General

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FJAbhaOmqOcxdABiY9ud7%2Fimage.png?alt=media&#x26;token=a9f6d699-9997-47d5-bda6-4d578cf01f32" alt=""><figcaption></figcaption></figure>

### &#x20;Active

Enable/Disable the Aim Logic. Use this to avoid doing raycasting while the aim component is not used.

### Update Mode

Where the Aim Logic will take place, on the **Fixed** or **Late Update** cycle.

### Aim Side

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-MJXZ-sObdGyzxd_PJ-t%2F-MJXde9vaKFjSiGueacU%2Fimage.png?alt=media\&token=49d5de17-1097-4281-8a44-ad77cb5f0594)

It's used for planning whether your Camera Rig can be on the Left or Right side of your character when aiming.

&#x20;It uses the On Aim event to send the value **-1** if the camera is on the **Left** side, **1** if is on the **Right** side, or **0** if the Amining logic is not Active.

### Aim Origin

The Transform object used to determine the origin position of the Aim Ray. Usually the head of the character.

### Layer

Which layers the Aim Ray will interact with&#x20;

### Trigger interaction

Will the Aim Ray interact with triggers?

### Raycast Radius

If this value is greater than zero, the Aim Ray will be using SphereCast instead of RayCast.&#x20;

### Ray Hits

Increase the precision of the Raycasting logic.&#x20;

Since I'm using the NonAlloc Version to make faster raycasting, this doesn't always create accurate Hits when the ray touches more than one object.  Increasing the hits increases the accuracy.

### Smoothness

Lerp value for changing the Ray cast hit position. Lower values, smooth Aiming

![Low Smoothness Value](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-MJXZ-sObdGyzxd_PJ-t%2F-MJXlBA_JLANRCHJvLFY%2FQlTy2XXAr5.gif?alt=media\&token=918fcd4b-ca09-4c0c-84c4-117e664c2b8a)

![High Smoothness value](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-MJXlYkZzI7zsn-RxtYS%2F-MJXlZwue-d9Fo-vGStz%2FszHcm9kDDx.gif?alt=media\&token=2413ddfd-8878-4bc7-8250-76c5f0296ad7)

## References

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2F8Qoom1G3vGoHTjR6evV9%2Fimage.png?alt=media&#x26;token=adeb5f95-c74c-4475-a681-fe115a251776" alt=""><figcaption></figcaption></figure>

### Target

Replaces the Aim Logic from Aiming with the Camera to Aiming towards a target.&#x20;

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-MJXlYkZzI7zsn-RxtYS%2F-MJXmlriJHh_E7xD4db0%2Fqv0frMmtGT.gif?alt=media\&token=4eaead48-155d-41be-9cc9-53010c402cc8)

### Use Camera

The Aim Target will use a camera to cast a ray from the camera's position

### Camera

Reference for the Main Camera

### Screen Center

When using a Camera as the Ray Origin. An offset will be added to the center of the screen where the Ray will be cast.

### Ignore

Extra Transform Reference to Ignore for the Aim Logic. This is used for example with the Rider when is mounting the horse and the Weapon is Aiming. The Horse is set as the extra transform so Aim Ray does not hit the horse gameobject and its children.

### Aim Position

It moves the Transform assigned to this parameter to the Hit Position. It is used to create an assistance to see where the Aim Ray Ends. It also hides this transform when the Aim is not Active.

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-MJXlYkZzI7zsn-RxtYS%2F-MJXo0R7C7eITfOUVRTS%2Fimage.png?alt=media\&token=76a58dc2-7e28-430b-9a93-70bf60a6703d)

## Events

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FxJmhyeesnSWcOI4mMqCm%2Fimage.png?alt=media&#x26;token=0f8d89bb-cfd8-4d69-a6b9-2d54db1f6829" alt=""><figcaption></figcaption></figure>

### On Aiming (Boolean)

Invoked when the Aim Logic is Enabled/Disabled

### On Hit (Transform)

Invoked when an object is hit by the Aim Ray.&#x20;

### On Aim Ray Target (transform)

Invoke the Transform the Aim Ray touches.

### On Using Target ()

Invoked true or false when a new Target is assigned

### On Clear Target ()

Invoked when the Target on the Aim component is removed

### On Set Target ()

Invoked when a new Target object is assigned

### On Screen Center (Vector3)&#x20;

Invoke the current Screen position.

### On Aim Side (Int)&#x20;

Invoke -1 if the Main Camera or Target is on the Left or 1 if it's on the Right side of the character. Useful to change states on the Camera Rig System





