LitMotion
LitMotion copied to clipboard
VibrationHelper is not correct
I'm not getting the right results from a Punch tween:
With these values:
start = 0; strength = 1 frequency = 1 damping = 0
I would expect my value to go:
0 -> 1 -> 0
but instead, it's going:
1 -> 0
Gif of the issue:
Corrected version:
if (t == 1f || t == 0f) {
result = Vector3.zero;
return;
}
float angularFrequency = frequency * math.PI;
float dampingFactor = dampingRatio * frequency / math.PI2;
result = math.sin(angularFrequency * t) * math.pow(math.E, -dampingFactor * t) * strength;