Esempio n. 1
0
    public override void ExitState()
    {
        if (_controller.jump)
        {
            _controller.verticalSpeed = _controller.jumpSpeed;
            _controller.SetState(new JumpState(_controller));
        }

        CheckFloor(PlayerUtils.GetFloorColliders(_controller, _controller.feetOverlap.position));

        if (_controller.moveObject && _controller.moveObject.canMove && _controller.inputMoveObject && _controller.moveObject.HasFloor())
        {
            _controller.SetState(new PushState(_controller));
        }
    }
Esempio n. 2
0
    public override void Update()
    {
        currentTime += Time.deltaTime;
        var vector3D = PlayerUtils.RetargetVector(_controller.movementVector, _controller.cameraTransform, _controller.joystickDeadZone);

        _controller.RotateTowardsForward(vector3D);

        if (!UIManager.Instance.popUpEnabled)
        {
            vector3D *= Mathf.Lerp(_controller.minSpeed, _controller.maxSpeed, _controller.movementVector.magnitude);
        }
        else
        {
            vector3D *= _controller.minSpeed;
        }

        if (_controller.edgeAvailable && PlayerUtils.CanInteractWithEdge(_controller.transform.forward, _controller.edgeGameObject.transform.forward, _controller.angleToAllowClimbEdge))
        {
            ExitState();
        }

        _controller.verticalSpeed += Physics.gravity.y * Time.deltaTime * _controller.gravityMultiplier;
        vector3D.y = _controller.verticalSpeed;

        vector3D.x = vector3D.x * _controller.speedMultiplierWhenJump;
        vector3D.z = vector3D.z * _controller.speedMultiplierWhenJump;
        vector3D  += CheckResidualCollisions();

        _controller.characterController.Move(vector3D * Time.deltaTime);

        if (CheckFloor(PlayerUtils.GetFloorColliders(_controller, _controller.feetOverlap.position)))
        {
            _controller.LandingSound();
            ExitState();
        }
    }