From f6c0796f31e6dbe8b5a6617a02806a69db5d68d3 Mon Sep 17 00:00:00 2001 From: Jens Pitkanen Date: Thu, 22 Aug 2019 21:38:39 +0300 Subject: [PATCH] Add slow motion and make bobbing framerate-independent --- Assets/Scripts/Effects/Bobbing.cs | 4 ++-- Assets/Scripts/Effects/CameraFX.cs | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/Effects/Bobbing.cs b/Assets/Scripts/Effects/Bobbing.cs index b2a2b3d..719485d 100644 --- a/Assets/Scripts/Effects/Bobbing.cs +++ b/Assets/Scripts/Effects/Bobbing.cs @@ -27,10 +27,10 @@ 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; } } -} \ No newline at end of file +} diff --git a/Assets/Scripts/Effects/CameraFX.cs b/Assets/Scripts/Effects/CameraFX.cs index 697953f..5732098 100644 --- a/Assets/Scripts/Effects/CameraFX.cs +++ b/Assets/Scripts/Effects/CameraFX.cs @@ -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; }