Class CinemachineThirdPersonAim
An add-on module for CinemachineCamera that forces the LookAt point to the center of the screen, based on the Follow target's orientation, cancelling noise and other corrections. This is useful for third-person style aim cameras that want a dead-accurate aim at all times, even in the presence of positional or rotational noise.
Inheritance
Inherited Members
Namespace: Unity.Cinemachine
Assembly: Unity.Cinemachine.dll
Syntax
[AddComponentMenu("Cinemachine/Procedural/Rotation Control/Cinemachine Third Person Aim")]
[ExecuteAlways]
[DisallowMultipleComponent]
[HelpURL("https://docs.unity3d.com/Packages/com.unity.cinemachine@3.1/manual/CinemachineThirdPersonAim.html")]
public class CinemachineThirdPersonAim : CinemachineExtension
Fields
AimCollisionFilter
Objects on these layers will be detected.
Declaration
[Header("Aim Target Detection")]
[Tooltip("Objects on these layers will be detected")]
public LayerMask AimCollisionFilter
Field Value
Type | Description |
---|---|
LayerMask |
AimDistance
How far to project the object detection ray.
Declaration
[Tooltip("How far to project the object detection ray")]
public float AimDistance
Field Value
Type | Description |
---|---|
float |
IgnoreTag
Objects with this tag will be ignored.
It is a good idea to set this field to the target's tag.
Declaration
[Tooltip("Objects with this tag will be ignored. It is a good idea to set this field to the target's tag")]
public string IgnoreTag
Field Value
Type | Description |
---|---|
string |
NoiseCancellation
If set, camera noise will be adjusted to stabilize target on screen.
Declaration
[Tooltip("If set, camera noise will be adjusted to stabilize target on screen")]
public bool NoiseCancellation
Field Value
Type | Description |
---|---|
bool |
Properties
AimTarget
World space position of where the player would hit if a projectile were to be fired from the player origin. This may be different from state.ReferenceLookAt due to camera offset from player origin.
Declaration
public Vector3 AimTarget { get; }
Property Value
Type | Description |
---|---|
Vector3 |
Methods
PostPipelineStageCallback(CinemachineVirtualCameraBase, Stage, ref CameraState, float)
Sets the ReferenceLookAt to be the result of a raycast in the direction of camera forward. If an object is hit, point is placed there, else it is placed at AimDistance along the ray.
Declaration
protected override void PostPipelineStageCallback(CinemachineVirtualCameraBase vcam, CinemachineCore.Stage stage, ref CameraState state, float deltaTime)
Parameters
Type | Name | Description |
---|---|---|
CinemachineVirtualCameraBase | vcam | The virtual camera being processed |
CinemachineCore.Stage | stage | The current pipeline stage |
CameraState | state | The current virtual camera state |
float | deltaTime | The current applicable deltaTime |