Links

Aim

✔

Overview

The Aim Component is used to cast a Ray from the Aim Origin game object to the center of the camera or an assigned Target.
It is commonly used to Aim Weapons, do a Head Look At, Strafing logic.

Requirements

  • This component needs to have an Aim Origin reference.

General

Active

Enable/Disable the Aim Logic

Update Mode

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

Aim Side

It's used for planning whether your Camera Rig can be on the Left or Right side of your character when aiming.
It uses the On Aim event , broadcasting -1 if is 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

Transform reference 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

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.

Ray Hits

Increase the precision of the Raycasting logic.
Since I'm using the NonAlloc Version to make faster raycasting, this does'n't always create accurate Hits when the ray touches more than one object. Increasing the hits increase the accuracy

Smoothness

Lerp value for changing the Ray cast hit position. Lower values, smooth Aiming
Low Smoothness Value
High Smoothness value

References

Camera

Reference for the Main Camera

Screen Center

Center of the screen where the Ray will be cast.

Aim Target

Replaces the Aim Logic from Aiming with the Camera to Aiming towards a target.

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 the weapons do not hit your Horse.

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.

Events

On Aiming (Boolean)

Invoked when the Aim Logic is Enabled/Disabled

On Aim Ray Target (transform)

Invoke the Transform the Aim Ray touches.

On Screen Center (Vector3)

Invoke the current Screen position.

On Aim Side (Int)

Invoke -1 if the Main Camera or Target is on the Left or 1 if it's on the Right side of the character. Usefull to change States on the Camera Rig
​
​
​