Class SmartFollowVector3TweenableVariable
This class expands on the vector3 tweenable variable to introduce two concepts:
- A dynamic threshold distance that grows over time in a range, that prevents updating the target so long as the value being assigned to the target is within that threshold.
- A variable speed tween (HandleSmartTween(float, float, float)) that inputs a lower and upper range speed for tweening. The closer the value is to the target, the faster the tween.
Inheritance
Inherited Members
Namespace: UnityEngine.XR.Interaction.Toolkit.Utilities.Tweenables.SmartTweenableVariables
Assembly: Unity.XR.Interaction.Toolkit.dll
Syntax
public class SmartFollowVector3TweenableVariable : Vector3TweenableVariable, IReadOnlyBindableVariable<float3>, IDisposable
Constructors
SmartFollowVector3TweenableVariable(float, float, float)
Initializes and returns an instance of SmartFollowVector3TweenableVariable.
Declaration
public SmartFollowVector3TweenableVariable(float minDistanceAllowed = 0.01, float maxDistanceAllowed = 0.3, float minToMaxDelaySeconds = 3)
Parameters
Type | Name | Description |
---|---|---|
float | minDistanceAllowed | Minimum distance from target before which tween starts. |
float | maxDistanceAllowed | Maximum distance from target before tween targets, when time threshold is reached. |
float | minToMaxDelaySeconds | Time required to elapse (in seconds) before the max distance allowed goes from the min distance to the max. |
See Also
Properties
maxDistanceAllowed
Maximum distance from target before tween targets, when time threshold is reached.
Declaration
public float maxDistanceAllowed { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
minDistanceAllowed
Minimum distance from target before which tween starts.
Declaration
public float minDistanceAllowed { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
minToMaxDelaySeconds
Time required to elapse before the max distance allowed goes from the min distance to the max.
Declaration
public float minToMaxDelaySeconds { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
Methods
HandleSmartTween(float, float, float)
Tween to new target with variable speed according to distance from target. The closer the target is to the current value, the faster the tween.
Declaration
public void HandleSmartTween(float deltaTime, float lowerSpeed, float upperSpeed)
Parameters
Type | Name | Description |
---|---|---|
float | deltaTime | Time in seconds since the last frame (such as deltaTime). |
float | lowerSpeed | Lower range speed for tweening. |
float | upperSpeed | Upper range speed for tweening. |
See Also
IsNewTargetWithinThreshold(float3)
Checks if the squared distance between the current target and a new target is within a dynamically determined threshold, based on the time since the last update.
Declaration
public bool IsNewTargetWithinThreshold(float3 newTarget)
Parameters
Type | Name | Description |
---|---|---|
float3 | newTarget | The new target position as a float3 vector. |
Returns
Type | Description |
---|---|
bool | Returns true if the squared distance between the current and new targets is within the allowed threshold, false otherwise. |
See Also
OnTargetChanged(float3)
Callback when new tween target value is assigned.
Declaration
protected override void OnTargetChanged(float3 newTarget)
Parameters
Type | Name | Description |
---|---|---|
float3 | newTarget | New target value. |
Overrides
See Also
SetTargetWithinThreshold(float3)
Updates the target position to a new value if it is within a dynamically determined threshold, based on the time since the last update.
Declaration
public bool SetTargetWithinThreshold(float3 newTarget)
Parameters
Type | Name | Description |
---|---|---|
float3 | newTarget | The new target position as a float3 vector. |
Returns
Type | Description |
---|---|
bool | Returns Returns true if the target position is updated, Returns false otherwise. |