Over Time Helper
The OverTimeHelper
provides you with a simple and easy way to step values over time.
The class also provides an intuitive, easy-to-use inspector for editing the options.
Overview​
The OverTimeHelper
class includes functionalities for:
- Stepping float, Vector2, Vector3, Quaternion, and Color values over time.
- An intuitive, easy-to-use inspector for editing the options.
Example​
Here's an example of a node that uses the OverTimeHelper
.
This node moves the inputted transform to the set target position.
The OverTimeHelper
in this instance is used to move the transform position over time.
using Jungle;
using Jungle.Extensions;
using UnityEngine;
[IONode(
OutputPortType = typeof(Transform)
)]
public class SetPositionNode : IONode<Transform>
{
[SerializeField]
private Vector3 position;
// Initialize the over time helper with good options
[SerializeField]
private OverTimeHelper overTime = OverTimeHelper.Default;
private Transform _transform;
protected override void OnStart(Transform transform)
{
_transform = transform;
}
protected override void OnUpdate()
{
// Step the transform position toward the target position
_transform.position = overTime.Step(_transform.position, position);
// Stop the node once the target position has been reached
if (overTime.IsDone)
CallAndStop(_transform);
}
}
Constructor​
OverTimeHelper
​
public OverTimeHelper(bool enabled, bool scaledTime, float rate, Motion method, float precision = 0.01f)
Initializes a new instance of the OverTimeHelper
class.
Parameters​
enabled
: Whether the helper is enabled.scaledTime
: Whether to use scaled delta time or fixed delta time for step calculations.rate
: The timescale rate.method
: The motion calculation method.precision
: The precision for determining if the calculation is done (default is 0.01f).
Properties​
enabled
​
public bool enabled { get; set; }
If the OverTimeHelper
is enabled.
While enabled = false
, step will immediately step the value to the target value.
scaledTime
​
public bool scaledTime { get; set; }
If the step calculations should be calculated with scaled time or fixed time.
rate
​
public float rate { get; set; }
The rate at which the step calculations should be calculated.
method
​
public OverTimeHelper.Motion method { get; set; }
The method used to calculate the steps.