コード例 #1
0
        public void Tick()
        {
            if (_player.Grounder.IsGrounded)
            {
                return;
            }

            IsTouchingWallRight = IsTouchingWallRightTest;
            IsTouchingWallLeft  = IsTouchingWallLeftTest;
            IsTouchingWall      = IsTouchingWallRight || IsTouchingWallLeft;

            if (IsTouchingWallRight && RewiredPlayerInput.Instance.MovingRight ||
                IsTouchingWallLeft && RewiredPlayerInput.Instance.MovingLeft)
            {
                Vector2 velocity = _rigidbody.velocity;
                _rigidbody.velocity =
                    new Vector2(velocity.x, Mathf.Clamp(velocity.y, -_fallingVelocity, float.MaxValue));
                HoldingWall = true;
            }
            else
            {
                HoldingWall = false;
            }

            if (RewiredPlayerInput.Instance.InitiateJump && IsTouchingWall)
            {
                if (IsTouchingWallRight)
                {
                    _rigidbody.velocity = _jumpForce;
                }
                else if (IsTouchingWallLeft)
                {
                    _rigidbody.velocity = _jumpForce.ReflectXAxis();
                }

                HoldingWall     = false;
                _player.CanMove = false;
                _player.StartCoroutine(WaitUntilTurnMoverBackOn());
            }

            _playerAnimator.HoldWall(HoldingWall);
        }