To tween a hardstep function in C#, you can use an easing function from a tweening library like Robert Penner's easing functions. Here is an example using the EasingFunctions library by Wouter van Oortmerssen:
main.cs692 chars28 linesHere, we use the Easing.HardStep function from the EasingFunctions library to perform the tweening. The time variable tracks the elapsed time since the start of the tween, and the duration variable specifies the length of the tween in seconds. The startValue and endValue variables represent the starting and ending values of the tween.
In the Update method, we call the Easing.HardStep function with the time, startValue, endValue - startValue, and duration arguments to calculate the tweened value. We then update the time variable with the elapsed time since the last frame using Time.deltaTime.
When the tween is finished (i.e., time exceeds duration), we reset the time, startValue, and endValue variables to tween in the opposite direction.
gistlibby LogSnag