From 603f77b0d466a05c189720ef18ceeb54e027c3f8 Mon Sep 17 00:00:00 2001 From: silver-ymz Date: Wed, 27 Mar 2024 17:45:19 +0800 Subject: [PATCH] fix: limit map fall speed Signed-off-by: silver-ymz --- Assets/Scripts/MoveBehaviour.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Assets/Scripts/MoveBehaviour.cs b/Assets/Scripts/MoveBehaviour.cs index 18d786f..7698411 100644 --- a/Assets/Scripts/MoveBehaviour.cs +++ b/Assets/Scripts/MoveBehaviour.cs @@ -16,6 +16,7 @@ public class MoveBehaviour : IManualBehaviour const float kJumpForce = 37.0f; // Each deep jump is 7 units high const float kFallMultiplier = 8f; const float kLowJumpMultiplier = 10f; + const float kMaxFallSpeed = -60f; const float kCoyoteTime = 0.15f; const float kConsumeTime = 0.05f; float lastGroundTime = 0; @@ -107,6 +108,11 @@ void BetterJump() { rigidBody.velocity += kLowJumpMultiplier * Physics2D.gravity.y * Time.fixedDeltaTime * Vector2.up; } + // limit the max fall speed + if (rigidBody.velocity.y < kMaxFallSpeed) + { + rigidBody.velocity = new Vector2(rigidBody.velocity.x, kMaxFallSpeed); + } } void UpdateGroundTime()