Class Cinemachine3rdPersonAim
An add-on module for Cinemachine Virtual Camera 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: Cinemachine
Syntax
[AddComponentMenu("")]
[ExecuteAlways]
[DisallowMultipleComponent]
public class Cinemachine3rdPersonAim : 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 |
---|---|
Single |
AimTargetReticle
This 2D object will be positioned in the game view over the raycast hit point, if any, or will remain in the center of the screen if no hit point is detected. May be null, in which case no on-screen indicator will appear.
Declaration
[Tooltip("This 2D object will be positioned in the game view over the raycast hit point, if any, or will remain in the center of the screen if no hit point is detected. May be null, in which case no on-screen indicator will appear")]
public RectTransform AimTargetReticle
Field Value
Type | Description |
---|---|
RectTransform |
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 |
Methods
OnTransitionFromCamera(ICinemachineCamera, Vector3, Single)
Notification that this virtual camera is going live.
Declaration
public override bool OnTransitionFromCamera(ICinemachineCamera fromCam, Vector3 worldUp, float deltaTime)
Parameters
Type | Name | Description |
---|---|---|
ICinemachineCamera | fromCam | The camera being deactivated. May be null. |
Vector3 | worldUp | Default world Up, set by the CinemachineBrain |
Single | deltaTime | Delta time for time-based effects (ignore if less than or equal to 0) |
Returns
Type | Description |
---|---|
Boolean | True to request a vcam update of internal state |
Overrides
PostPipelineStageCallback(CinemachineVirtualCameraBase, CinemachineCore.Stage, ref CameraState, Single)
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.
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 |
Single | deltaTime | The current applicable deltaTime |