Replaced magic numbers with constants

This commit is contained in:
OverflowNarhoym 2022-02-22 19:07:11 +01:00
parent 9160a0092a
commit 643460f392
1 changed files with 6 additions and 3 deletions

View File

@ -14,6 +14,9 @@ namespace Player
private const float MaxSpeed = 500.0f;
private const float DefaultAirSpeed = 300.0f;
private const float GravityScale = 5.0f;
private const float AccelerationScale = 40.0f;
private const float DecelerationScale = 60.0f;
private const float RespawnLimit = -60.0f;
private const float FallMultiplier = 4.0f;
private const float LowJumpMultiplier = 4.0f;
@ -110,7 +113,7 @@ namespace Player
private void RespawnCheck()
{
if (gameObject.transform.position.y < -100)
if (gameObject.transform.position.y < RespawnLimit)
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
@ -164,14 +167,14 @@ namespace Player
}
if (!_isOnAir)
BaseSpeed += 40;
BaseSpeed += AccelerationScale;
_playerRigidbody2D.velocity = new Vector2(BaseSpeed * _xAxisValue * Time.fixedDeltaTime,
_playerRigidbody2D.velocity.y);
}
private void DecelerationAfterMoving()
{
BaseSpeed -= 80;
BaseSpeed -= DecelerationScale;
_playerRigidbody2D.velocity = new Vector2(BaseSpeed * (int)_orientation * Time.fixedDeltaTime,
_playerRigidbody2D.velocity.y);
if (BaseSpeed == 0)