Add slow motion and make bobbing framerate-independent

This commit is contained in:
Jens Pitkänen 2019-08-22 21:38:39 +03:00
parent 007653eb54
commit f6c0796f31
2 changed files with 9 additions and 3 deletions

View File

@ -27,7 +27,7 @@ namespace Saltosion.OneWeapon.Effects {
if (CurrentBobbingState <= 0) {
BobbingSpeed = (BobbingLaunchSpeed / 10);
}
CurrentBobbingState += BobbingSpeed * BobbingMultiplier;
CurrentBobbingState += BobbingSpeed * BobbingMultiplier * Time.deltaTime * 100.0f;
BobbedTransform.localPosition = BobbingDirection * CurrentBobbingState * BobbingMultiplier;

View File

@ -25,6 +25,7 @@ namespace Saltosion.OneWeapon.Effects {
private void Update() {
if (TimeStopCooldown > 0) {
TimeStopCooldown -= Time.deltaTime / Time.timeScale;
if (TimeStopCooldown <= 0) {
Time.timeScale = 1.0f;
}
@ -42,7 +43,12 @@ namespace Saltosion.OneWeapon.Effects {
}
public void StopFor(float seconds) {
Time.timeScale = 0.05f;
Time.timeScale = 0.01f;
TimeStopCooldown = seconds;
}
public void SlowMotion(float timeScale, float seconds) {
Time.timeScale = timeScale;
TimeStopCooldown = seconds;
}