Smooth
The Smooth module allows for silky-smooth movements. It is great for camera damping and smooth movement effects.
The underlying concept is to feed the Smooth object a Vector3 goal, and the algorithm will smoothly move toward that goal.
Constructor¶
Smooth.new(Vector3 initialValue, Number smoothTime)
¶
Constructs a new Smooth object. The initialValue
is the starting point for the smoother, and the smoothTime
is the amount of time it takes for the algorithm to reach its goal.
1 |
|
Tip
Keep the smoothTime
as low as possible. While smoothing effects are fun to make, the players will be annoyed by transitions and movements that are too slow.
Methods¶
Update([Vector3 goal])
¶
Calculate the new value based on the goal.
1 2 3 4 5 6 |
|
UpdateAngle([Vector3 goal])
¶
The same as Update
, but will wrap the value around Tau (2π), which is a full circle in radians. This is necessary if the Smooth object is being used to calculate any sort of rotation (e.g. camera rotation).
1 2 |
|
SetMaxSpeed(Number speed)
¶
Set the max speed at which the smoothing algorithm can travel. By default, there is no maximum speed.
1 2 |
|
GetMaxSpeed()
¶
Gets the max speed set for the smoothing algorithm.
1 |
|
Properties¶
Value
¶
The current Vector3 value calculated by the smoothing algorithm.
Goal
¶
The current Vector3 goal that the smoothing algorithm is moving toward.
SmoothTime
¶
The time it takes for the smoothing algorithm to reach the goal.
Example¶
1 2 3 4 5 6 7 8 |
|