Exemplo n.º 1
0
    public override void OnUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        base.OnUpdate(animator, stateInfo, layerIndex);

        //匍匐
        if (VirtualInputManager.Instance.IsCrouch && detector.IsOnGround())
        {
            animator.SetBool(AnimParameterType.IsCrouch.ToString(), true);
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 基础运动
    /// </summary>
    /// <param name="animator"></param>
    void BasicMotionControl(Animator animator)
    {
        //跳跃
        if (VirtualInputManager.Instance.IsJump && detector.IsOnGround() && !isJump)
        {
            animator.SetBool(AnimParameterType.IsJump.ToString(), true);
            isJump = true;
            return;
        }
        //匍匐
        if (VirtualInputManager.Instance.IsCrouch && detector.IsOnGround())
        {
            animator.SetBool(AnimParameterType.IsCrouch.ToString(), true);
        }

        //左右同时(松开)按下.角色不移动.
        if (VirtualInputManager.Instance.IsRight && VirtualInputManager.Instance.IsLeft)
        {
            animator.SetBool(AnimParameterType.IsRun.ToString(), false);
            Character.Rig.velocity = Vector3.zero;
            return;
        }
        if (!VirtualInputManager.Instance.IsRight && !VirtualInputManager.Instance.IsLeft)
        {
            animator.SetBool(AnimParameterType.IsRun.ToString(), false);
            Character.Rig.velocity = Vector3.zero;
            return;
        }
        //右移
        if (VirtualInputManager.Instance.IsRight)
        {
            animator.SetBool(AnimParameterType.IsRun.ToString(), true);
            Character.Rig.velocity = moveSpeed * Vector3.right;
            Character.transform.localEulerAngles = new Vector3(0, 90, 0);
        }
        //左移
        if (VirtualInputManager.Instance.IsLeft)
        {
            animator.SetBool(AnimParameterType.IsRun.ToString(), true);
            Character.Rig.velocity = moveSpeed * Vector3.left;
            Character.transform.localEulerAngles = new Vector3(0, -90, 0);
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// (基础)运动控制
    /// </summary>
    void BasicMotionControl(Animator animator)
    {
        //跳跃
        if (VirtualInputManager.Instance.IsJump && detector.IsOnGround() && !isJump)
        {
            animator.SetBool(AnimParameterType.IsJump.ToString(), true);
            isJump = true;
            return;
        }
        //匍匐
        if (VirtualInputManager.Instance.IsCrouch && detector.IsOnGround())
        {
            animator.SetBool(AnimParameterType.IsCrouch.ToString(), true);
        }

        //左右同时按下.角色不移动.
        if (VirtualInputManager.Instance.IsRight && VirtualInputManager.Instance.IsLeft)
        {
            animator.SetBool(AnimParameterType.IsRun.ToString(), false);
            return;
        }
        if (!VirtualInputManager.Instance.IsLeft && !VirtualInputManager.Instance.IsRight)
        {
            animator.SetBool(AnimParameterType.IsRun.ToString(), false);
            return;
        }

        //右移
        if (VirtualInputManager.Instance.IsRight && !VirtualInputManager.Instance.IsLeft)
        {
            animator.SetBool(AnimParameterType.IsRun.ToString(), true);
        }
        //左移
        else if (VirtualInputManager.Instance.IsLeft && !VirtualInputManager.Instance.IsRight)
        {
            animator.SetBool(AnimParameterType.IsRun.ToString(), true);
        }
    }
Exemplo n.º 4
0
    public override void OnUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        base.OnUpdate(animator, stateInfo, layerIndex);

        bool isOnGround = detector.IsOnGround();

        if (isOnGround)
        {
            animator.SetBool(AnimParameterType.IsFall.ToString(), false);
            animator.SetBool(AnimParameterType.IsCanJump.ToString(), true);
        }
        else
        {
            animator.SetBool(AnimParameterType.IsCanJump.ToString(), false);
            animator.SetBool(AnimParameterType.IsFall.ToString(), true);
        }
    }
Exemplo n.º 5
0
    public override void OnUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        base.OnUpdate(animator, stateInfo, layerIndex);

        //匍匐
        if (VirtualInputManager.Instance.IsCrouch && detector.IsOnGround())
        {
            animator.SetBool(AnimParameterType.IsCrouch.ToString(), true);
        }

        //左移
        if (VirtualInputManager.Instance.IsLeft)
        {
            Character.transform.Translate(-Vector3.right * Time.deltaTime * airMoveSpeed, Space.World);
        }
        //左移
        if (VirtualInputManager.Instance.IsRight)
        {
            Character.transform.Translate(Vector3.right * Time.deltaTime * airMoveSpeed, Space.World);
        }
    }