Пример #1
0
    public void Tick()
    {
        ////Run initial mover ground check;
        //mover.CheckForGround();
        _characterMover.CheckForGround();

        _state = DetermineControllerState();
        OnStateChange?.Invoke(_state);
        //Debug.Log("STATE:"+_state.ToString());

        //Apply friction and gravity to 'momentum';
        ////HandleMomentum();

        var Jumping = HandleJump();

        Vector3 _velocity = Vector3.zero;

        //If player is grounded or sliding on a slope, extend mover's sensor range;
        //This enables the player to walk up/down stairs and slopes without losing ground contact;
        _characterMover.SetExtendSensorRange(IsGrounded());


        //Set Velocity
        if (IsGrounded())
        {
            _characterMover.SetVelocity(_previousVelocity + _characterMover.GetCurrentGroundAdjustmentVelocity());
            if (_RootMotionDelta.canRotate)
            {
                CalculateCharacterDesiredVector();
                RotateTransform(DesiredCharacterVectorForward);
            }
            SendAnimatorLocomotionCommands(_characterInput.IsRunning());
        }
    }