LitMotion icon indicating copy to clipboard operation
LitMotion copied to clipboard

VibrationHelper is not correct

Open cfoulston opened this issue 10 months ago • 0 comments

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:

Image

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;

Image

cfoulston avatar Mar 28 '25 20:03 cfoulston