Example #1
0
    private void FixedUpdate()
    {
        if (xInput < 0)
        {
            isFacingLeft = true;
        }
        else if (xInput > 0)
        {
            isFacingLeft = false;
        }

        float yValue = 0;

        if (lastYInput != yInput || CurrentSetting.CharacterSettings.CanFly)
        {
            yValue     = yInput;
            lastYInput = yInput;
        }

        if (!_animController)
        {
            return;
        }
        _animController.SetFloat("xMove", xInput);
        _animController.SetBool("grounded", _entity._lastHitResult.hitDown);

        if (_sRend)
        {
            _sRend.flipX = isFacingLeft;
        }

        if (CurrentSetting.CharacterSettings.InstantVelocity)
        {
            HandleInstantVelocity(xInput, yValue);
        }
        else
        {
            _entity.AddToVelocity(new Vector3(xInput * CurrentSetting.CharacterSettings.Speed, CurrentSetting.CharacterSettings.CanFly ? yValue * CurrentSetting.CharacterSettings.JumpStrength : 0, 0));
        }
    }