Skip to content

Commit 0745193

Browse files
committed
https://github.com/annulusgames/LitMotion/pull/253
Fix vibration flicker at start annulusgames#253
1 parent 67de6eb commit 0745193

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/LitMotion/Assets/LitMotion/Runtime/Internal/VibrationHelper.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ public static void EvaluateStrength(in float strength, in int frequency, in floa
1515
result = 0f;
1616
return;
1717
}
18-
float angularFrequency = (frequency - 0.5f) * math.PI;
18+
float angularFrequency = (frequency * t - 0.5f) * math.PI;
1919
float dampingFactor = dampingRatio * frequency / (2f * math.PI);
20-
result = strength * math.pow(math.E, -dampingFactor * t) * math.cos(angularFrequency * t);
20+
result = strength * math.pow(math.E, -dampingFactor * t) * math.cos(angularFrequency);
2121
}
2222

2323
[BurstCompile]
@@ -28,9 +28,9 @@ public static void EvaluateStrength(in Vector2 strength, in int frequency, in fl
2828
result = Vector2.zero;
2929
return;
3030
}
31-
float angularFrequency = (frequency - 0.5f) * math.PI;
31+
float angularFrequency = (frequency * t - 0.5f) * math.PI;
3232
float dampingFactor = dampingRatio * frequency / (2f * math.PI);
33-
result = math.cos(angularFrequency * t) * math.pow(math.E, -dampingFactor * t) * strength;
33+
result = math.cos(angularFrequency) * math.pow(math.E, -dampingFactor * t) * strength;
3434
}
3535

3636
[BurstCompile]
@@ -41,9 +41,9 @@ public static void EvaluateStrength(in Vector3 strength, in int frequency, in fl
4141
result = Vector3.zero;
4242
return;
4343
}
44-
float angularFrequency = (frequency - 0.5f) * math.PI;
44+
float angularFrequency = (frequency * t - 0.5f) * math.PI;
4545
float dampingFactor = dampingRatio * frequency / (2f * math.PI);
46-
result = math.cos(angularFrequency * t) * math.pow(math.E, -dampingFactor * t) * strength;
46+
result = math.cos(angularFrequency) * math.pow(math.E, -dampingFactor * t) * strength;
4747
}
4848
}
4949
}

0 commit comments

Comments
 (0)