docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class TargetPositionCache

    Use this class to support caching of Cinemachine target positions and rotations for the purposes of timeline scrubbing in the Editor. At runtime, the public methods in this class simply return the uncached values from the target's transform.

    Cinemachine behaviours and extensions that support timeline scrubbing should use the GetTargetPosition and GetTargetRotation static methods when accessing the target's position or rotation.

    Inheritance
    object
    TargetPositionCache
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.Cinemachine
    Assembly: Unity.Cinemachine.dll
    Syntax
    public class TargetPositionCache

    Methods

    GetTargetPosition(Transform)

    When using Timeline in Edit mode:

    • If you're Recording, the method logs the target position at the CurrentTime.
    • Otherwise, it fetches the cached position at CurrentTime.

    When using Timeline in Play mode, and when you're not scrubbing it:

    • The method returns the position directly from the Transform.
    Declaration
    public static Vector3 GetTargetPosition(Transform target)
    Parameters
    Type Name Description
    Transform target

    Target whose transform is tracked

    Returns
    Type Description
    Vector3

    The effective position of the target.

    GetTargetRotation(Transform)

    When using Timeline in Edit mode:

    • If you're Recording, the method logs the target position at the CurrentTime.
    • Otherwise, it fetches the cached position at CurrentTime.

    When using Timeline in Play mode, and when you're not scrubbing it:

    • The method returns the position directly from the Transform.
    Declaration
    public static Quaternion GetTargetRotation(Transform target)
    Parameters
    Type Name Description
    Transform target

    Target whose transform is tracked

    Returns
    Type Description
    Quaternion

    The effective position of the target.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)