Skip to content

Commit

Permalink
fix: limit map fall speed
Browse files Browse the repository at this point in the history
Signed-off-by: silver-ymz <[email protected]>
  • Loading branch information
silver-ymz committed Mar 27, 2024
1 parent 36a80c8 commit 603f77b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Assets/Scripts/MoveBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 603f77b

Please sign in to comment.