Modified scene

This commit is contained in:
OverflowNarhoym
2022-02-21 22:48:53 +01:00
parent f642c12d56
commit 961c8cf865
4 changed files with 419 additions and 114 deletions

View File

@@ -7,10 +7,10 @@ namespace Player
{
public class PlayerController : MonoBehaviour, IMovement, Input.PlayerInput.IPlayerControlActions
{
private const float DefaultJumpForce = 1200.0f;
private const float DefaultJumpForce = 9.81f;
private const float DefaultMass = 80.0f;
private const float DefaultSpeed = 500.0f;
private const float GravityScale = 3.0f;
private const float GravityScale = 1.0f;
private Input.PlayerInput _controls;
private Rigidbody2D _playerRigidbody2D;
@@ -85,16 +85,12 @@ namespace Player
public void Move(float value)
{
switch (_xAxisValue)
_playerSpriteRenderer.flipX = _xAxisValue switch
{
case < 0:
_playerSpriteRenderer.flipX = true;
break;
case > 0:
_playerSpriteRenderer.flipX = false;
break;
}
< 0 => true,
> 0 => false,
_ => _playerSpriteRenderer.flipX
};
_playerRigidbody2D.velocity = new Vector2(BaseSpeed * _xAxisValue * Time.fixedDeltaTime,
_playerRigidbody2D.velocity.y);
}
@@ -102,7 +98,7 @@ namespace Player
private void Jump()
{
_playerRigidbody2D.velocity = new Vector2(_playerRigidbody2D.velocity.x, 0);
_playerRigidbody2D.AddForce(Vector2.up.normalized * DefaultJumpForce, ForceMode2D.Impulse);
_playerRigidbody2D.AddForce(Vector2.up.normalized * DefaultJumpForce * DefaultMass, ForceMode2D.Impulse);
}
private void Climb()