Class LazyFollow
Makes the GameObject this component is attached to follow a target with a delay and some other layout options.
Inherited Members
Namespace: UnityEngine.XR.Interaction.Toolkit.UI
Assembly: solution.dll
Syntax
[AddComponentMenu("XR/Lazy Follow", 22)]
[HelpURL("https://docs.unity.cn/Packages/com.unity.xr.interaction.toolkit@3.0/api/UnityEngine.XR.Interaction.Toolkit.UI.LazyFollow.html")]
public class LazyFollow : MonoBehaviour
Properties
| Name | Description |
|---|---|
| applyTargetInLocalSpace | If true, apply the target offset in local space. If false, apply the target offset in world space. |
| 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. |
| maxAngleAllowed | Maximum angle offset (in degrees) from target before lazy follow targets, when time threshold is reached |
| maxDistanceAllowed | Maximum distance from target before lazy follow targets, when time threshold is reached. |
| minAngleAllowed | Minimum angle offset (in degrees) from target before which lazy follow starts. |
| minDistanceAllowed | Minimum distance from target before which a follow lazy follow starts. |
| movementSpeed | Movement speed used when smoothing to new target. Lower values mean the lazy follow lags further behind the target. |
| 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. |
| positionFollowMode | Determines the follow mode used to determine a new rotation. |
| rotationFollowMode | Determines the follow mode used to determine a new rotation. |
| snapOnEnable | Snap to target position when this component is enabled. |
| target | The object being followed. If not set, this will default to the main camera when this component is enabled. |
| targetOffset | The amount to offset the target's position when following. This position is relative/local to the target object. |
| timeUntilThresholdReachesMaxAngle | Time required to elapse (in seconds) before the max angle offset allowed goes from the min angle offset to the max. |
| timeUntilThresholdReachesMaxDistance | The time threshold (in seconds) where if max distance is reached the lazy follow capability will not be turned off. |
Methods
| Name | Description |
|---|---|
| Awake() | See MonoBehaviour. |
| LateUpdate() | See MonoBehaviour. |
| OnDestroy() | See MonoBehaviour. |
| OnDisable() | See MonoBehaviour. |
| OnEnable() | See MonoBehaviour. |
| OnValidate() | See MonoBehaviour. |
| 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. |
| 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. |