Class SmartFollowQuaternionTweenableVariable
This class expands on the Quaternion tweenable variable to introduce two concepts:
- A dynamic threshold angle 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(Single, Single, Single)) 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
Syntax
public class SmartFollowQuaternionTweenableVariable : QuaternionTweenableVariable, IReadOnlyBindableVariable<Quaternion>
Constructors
SmartFollowQuaternionTweenableVariable(Single, Single, Single)
Constructor for SmartFollowQuaternionTweenableVariable.
Declaration
public SmartFollowQuaternionTweenableVariable(float minAngleAllowed = 0.1F, float maxAngleAllowed = 5F, float minToMaxDelaySeconds = 3F)
Parameters
Type | Name | Description |
---|---|---|
Single | minAngleAllowed | Minimum angle offset (in degrees) from target before which tween starts. |
Single | maxAngleAllowed | Maximum angle offset (in degrees) from target before tween targets, when time threshold is reached. |
Single | minToMaxDelaySeconds | Time required to elapse (in seconds) before the max angle offset allowed goes from the min angle offset to the max. |
Properties
maxAngleAllowed
Maximum angle offset allowed in degrees.
Declaration
public float maxAngleAllowed { get; set; }
Property Value
Type | Description |
---|---|
Single |
minAngleAllowed
Minimum angle offset allowed in degrees.
Declaration
public float minAngleAllowed { get; set; }
Property Value
Type | Description |
---|---|
Single |
minToMaxDelaySeconds
Time required to elapse before the max angle offset allowed goes from the min angle to the max.
Declaration
public float minToMaxDelaySeconds { get; set; }
Property Value
Type | Description |
---|---|
Single |
Methods
HandleSmartTween(Single, Single, Single)
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 |
---|---|---|
Single | deltaTime | |
Single | lowerSpeed | |
Single | upperSpeed |
IsNewTargetWithinThreshold(Quaternion)
Checks if the angle difference between the current target rotation and a new target rotation is within a dynamically determined threshold, based on the time since the last update.
Declaration
public bool IsNewTargetWithinThreshold(Quaternion newTarget)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | newTarget | The new target rotation as a Quaternion. |
Returns
Type | Description |
---|---|
Boolean | Returns true if the angle difference between the current and new targets is within the allowed threshold, false otherwise. |
OnTargetChanged(Quaternion)
Callback when new tween target value is assigned.
Declaration
protected override void OnTargetChanged(Quaternion newTarget)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | newTarget |
Overrides
See Also
SetTargetWithinThreshold(Quaternion)
Updates the target rotation to a new value if it is within a dynamically determined threshold, based on the time since the last update.
Declaration
public bool SetTargetWithinThreshold(Quaternion newTarget)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | newTarget | The new target rotation as a Quaternion. |
Returns
Type | Description |
---|---|
Boolean | Returns true if the target rotation is updated, false otherwise. |