docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class LazyFollow

    Makes the GameObject this component is attached to follow a target with a delay and some other layout options.

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    LazyFollow
    Inherited Members
    MonoBehaviour.IsInvoking()
    MonoBehaviour.CancelInvoke()
    MonoBehaviour.Invoke(string, float)
    MonoBehaviour.InvokeRepeating(string, float, float)
    MonoBehaviour.CancelInvoke(string)
    MonoBehaviour.IsInvoking(string)
    MonoBehaviour.StartCoroutine(string)
    MonoBehaviour.StartCoroutine(string, object)
    MonoBehaviour.StartCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(Coroutine)
    MonoBehaviour.StopCoroutine(string)
    MonoBehaviour.StopAllCoroutines()
    MonoBehaviour.print(object)
    MonoBehaviour.useGUILayout
    MonoBehaviour.runInEditMode
    Behaviour.enabled
    Behaviour.isActiveAndEnabled
    Component.GetComponent(Type)
    Component.GetComponent<T>()
    Component.TryGetComponent(Type, out Component)
    Component.TryGetComponent<T>(out T)
    Component.GetComponent(string)
    Component.GetComponentInChildren(Type, bool)
    Component.GetComponentInChildren(Type)
    Component.GetComponentInChildren<T>(bool)
    Component.GetComponentInChildren<T>()
    Component.GetComponentsInChildren(Type, bool)
    Component.GetComponentsInChildren(Type)
    Component.GetComponentsInChildren<T>(bool)
    Component.GetComponentsInChildren<T>(bool, List<T>)
    Component.GetComponentsInChildren<T>()
    Component.GetComponentsInChildren<T>(List<T>)
    Component.GetComponentInParent(Type, bool)
    Component.GetComponentInParent(Type)
    Component.GetComponentInParent<T>(bool)
    Component.GetComponentInParent<T>()
    Component.GetComponentsInParent(Type, bool)
    Component.GetComponentsInParent(Type)
    Component.GetComponentsInParent<T>(bool)
    Component.GetComponentsInParent<T>(bool, List<T>)
    Component.GetComponentsInParent<T>()
    Component.GetComponents(Type)
    Component.GetComponents(Type, List<Component>)
    Component.GetComponents<T>(List<T>)
    Component.GetComponents<T>()
    Component.CompareTag(string)
    Component.SendMessageUpwards(string, object, SendMessageOptions)
    Component.SendMessageUpwards(string, object)
    Component.SendMessageUpwards(string)
    Component.SendMessageUpwards(string, SendMessageOptions)
    Component.SendMessage(string, object)
    Component.SendMessage(string)
    Component.SendMessage(string, object, SendMessageOptions)
    Component.SendMessage(string, SendMessageOptions)
    Component.BroadcastMessage(string, object, SendMessageOptions)
    Component.BroadcastMessage(string, object)
    Component.BroadcastMessage(string)
    Component.BroadcastMessage(string, SendMessageOptions)
    Component.transform
    Component.gameObject
    Component.tag
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(object)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, bool)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, bool)
    Object.Destroy(Object, float)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, bool)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.FindObjectsOfType(Type, bool)
    Object.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.DontDestroyOnLoad(Object)
    Object.FindObjectsOfType<T>()
    Object.FindObjectsByType<T>(FindObjectsSortMode)
    Object.FindObjectsOfType<T>(bool)
    Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
    Object.FindObjectOfType<T>()
    Object.FindObjectOfType<T>(bool)
    Object.FindFirstObjectByType<T>()
    Object.FindAnyObjectByType<T>()
    Object.FindFirstObjectByType<T>(FindObjectsInactive)
    Object.FindAnyObjectByType<T>(FindObjectsInactive)
    Object.FindObjectOfType(Type)
    Object.FindFirstObjectByType(Type)
    Object.FindAnyObjectByType(Type)
    Object.FindObjectOfType(Type, bool)
    Object.FindFirstObjectByType(Type, FindObjectsInactive)
    Object.FindAnyObjectByType(Type, FindObjectsInactive)
    Object.ToString()
    Object.name
    Object.hideFlags
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: UnityEngine.XR.Interaction.Toolkit.UI
    Assembly: Unity.XR.Interaction.Toolkit.dll
    Syntax
    [AddComponentMenu("XR/Lazy Follow", 22)]
    [HelpURL("https://docs.unity3d.com/Packages/com.unity.xr.interaction.toolkit@3.2/api/UnityEngine.XR.Interaction.Toolkit.UI.LazyFollow.html")]
    public class LazyFollow : MonoBehaviour

    Properties

    applyTargetInLocalSpace

    If true, apply the target offset in local space. If false, apply the target offset in world space.

    Declaration
    public bool applyTargetInLocalSpace { get; set; }
    Property Value
    Type Description
    bool

    followInLocalSpace

    If true, read the local transform of the target to lazy follow, otherwise read the world transform. If using look at rotation follow modes, only world-space follow is supported.

    Declaration
    public bool followInLocalSpace { get; set; }
    Property Value
    Type Description
    bool

    maxAngleAllowed

    Maximum angle offset (in degrees) from target before lazy follow targets, when time threshold is reached

    Declaration
    public float maxAngleAllowed { get; set; }
    Property Value
    Type Description
    float

    maxDistanceAllowed

    Maximum distance from target before lazy follow targets, when time threshold is reached.

    Declaration
    public float maxDistanceAllowed { get; set; }
    Property Value
    Type Description
    float

    minAngleAllowed

    Minimum angle offset (in degrees) from target before which lazy follow starts.

    Declaration
    public float minAngleAllowed { get; set; }
    Property Value
    Type Description
    float

    minDistanceAllowed

    Minimum distance from target before which a follow lazy follow starts.

    Declaration
    public float minDistanceAllowed { get; set; }
    Property Value
    Type Description
    float

    movementSpeed

    Movement speed used when smoothing to new target. Lower values mean the lazy follow lags further behind the target.

    Declaration
    public float movementSpeed { get; set; }
    Property Value
    Type Description
    float

    movementSpeedVariancePercentage

    Adjust movement speed based on distance from the target using a tolerance percentage. 0% for constant speed. For example, with a variance of 25% (0.25), and a speed of 6, the upper bound is 7.5, which is reached as the target is approached. If the target is far from the object, the speed will trend toward the lower bound, which would be 4.5 in this case.

    Declaration
    public float movementSpeedVariancePercentage { get; set; }
    Property Value
    Type Description
    float

    positionFollowMode

    Determines the follow mode used to determine a new rotation.

    Declaration
    public LazyFollow.PositionFollowMode positionFollowMode { get; set; }
    Property Value
    Type Description
    LazyFollow.PositionFollowMode

    rotationFollowMode

    Determines the follow mode used to determine a new rotation.

    Declaration
    public LazyFollow.RotationFollowMode rotationFollowMode { get; set; }
    Property Value
    Type Description
    LazyFollow.RotationFollowMode

    snapOnEnable

    Snap to target position when this component is enabled.

    Declaration
    public bool snapOnEnable { get; set; }
    Property Value
    Type Description
    bool

    target

    The object being followed. If not set, this will default to the main camera when this component is enabled.

    Declaration
    public Transform target { get; set; }
    Property Value
    Type Description
    Transform

    targetOffset

    The amount to offset the target's position when following. This position is relative/local to the target object.

    Declaration
    public Vector3 targetOffset { get; set; }
    Property Value
    Type Description
    Vector3

    timeUntilThresholdReachesMaxAngle

    Time required to elapse (in seconds) before the max angle offset allowed goes from the min angle offset to the max.

    Declaration
    public float timeUntilThresholdReachesMaxAngle { get; set; }
    Property Value
    Type Description
    float

    timeUntilThresholdReachesMaxDistance

    The time threshold (in seconds) where if max distance is reached the lazy follow capability will not be turned off.

    Declaration
    public float timeUntilThresholdReachesMaxDistance { get; set; }
    Property Value
    Type Description
    float

    Methods

    Awake()

    See MonoBehaviour.

    Declaration
    protected void Awake()

    LateUpdate()

    See MonoBehaviour.

    Declaration
    protected void LateUpdate()

    OnDestroy()

    See MonoBehaviour.

    Declaration
    protected void OnDestroy()

    OnDisable()

    See MonoBehaviour.

    Declaration
    protected void OnDisable()

    OnEnable()

    See MonoBehaviour.

    Declaration
    protected void OnEnable()

    OnValidate()

    See MonoBehaviour.

    Declaration
    protected void OnValidate()

    TryGetThresholdTargetPosition(out Vector3)

    Determines if the new target position is within a dynamically determined threshold based on the time since the last update, and outputs the new target position if it meets the threshold.

    Declaration
    protected virtual bool TryGetThresholdTargetPosition(out Vector3 newTarget)
    Parameters
    Type Name Description
    Vector3 newTarget

    The output new target position as a Vector3, if within the allowed threshold.

    Returns
    Type Description
    bool

    Returns true if the squared distance between the current and new target positions is within the allowed threshold, false otherwise.

    TryGetThresholdTargetRotation(out Quaternion)

    Determines if the new target rotation is within a dynamically determined threshold based on the time since the last update, and outputs the new target rotation if it meets the threshold.

    Declaration
    protected virtual bool TryGetThresholdTargetRotation(out Quaternion newTarget)
    Parameters
    Type Name Description
    Quaternion newTarget

    The output new target rotation as a Quaternion, if within the allowed threshold.

    Returns
    Type Description
    bool

    Returns true if the angle difference between the current and new target rotations is within the allowed threshold, false otherwise.

    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)