Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            var ray = mainCamera.ScreenPointToRay(Input.mousePosition);

            RaycastHit Hit;
            if (Physics.Raycast(ray, out Hit, Mathf.Infinity))
            {
                if (simpleAnimation.IsPlaying("idle"))
                {
                    simpleAnimation.CrossFade("run", 0.5f);
                }
                else if (simpleAnimation.IsPlaying("run"))
                {
                    simpleAnimation.CrossFade("idle", 0.5f);
                }
            }
        }
    }
Ejemplo n.º 2
0
    private void Update()
    {
        if (m_rb.velocity.magnitude > m_limitSpeed)
        {
            Debug.Log("はやすぎ");
            m_rb.velocity = new Vector3(m_rb.velocity.x / m_decelerateSpeed, m_rb.velocity.y / m_decelerateSpeed, m_rb.velocity.z / m_decelerateSpeed);
        }

        switch (PlayerState.m_PlayerStates)
        {
        case PlayerStates.InGame:
            if (m_canmove)    //here
            {
                m_horizontal = Input.GetAxisRaw("Horizontal");
                m_virtical   = Input.GetAxisRaw("Vertical");
                if (Input.GetButtonDown("Sprint"))
                {
                    Debug.Log("SprintButtonPushed");
                    if (!IsSprint && !LockOnController.IsLock)
                    {    // m_rb.velocity = Vector3.zero;
                        IsSprint = true;
                    }
                    else
                    {
                        IsSprint = false;
                    }
                }

                if (Input.GetButtonDown("Atack"))
                {
                    m_isAtacking = true;
                }
            }
            break;

        case PlayerStates.OpenUi:
            break;

        default:
            break;
        }


        m_dir = Vector3.forward * m_virtical + Vector3.right * m_horizontal;
        if (m_dir == Vector3.zero)
        {
            m_rb.velocity = new Vector3(0f, m_rb.velocity.y, 0f);
        }
        else if (LockOnController.IsLock)
        {
            /*ロックオン状態だと敵を見ながら動く*/
            LockOnMoveUpdate();
        }
        else
        {
            NormalMoveUpdate();
        }

        if (IsGround())
        {
            Debug.Log($"接地している:{m_isInTheAir}");
            m_isInTheAir = false;

            if (Input.GetButtonDown("Jump"))
            {
                Jump();
            }
        }
        else
        {
            Debug.Log($"接地していない");
            m_isInTheAir = true;
        }

        /*simpleAnimationに関する処理*/
        if (m_simpleAnim)
        {
            if (!IsGround())
            {
                if (m_rb.velocity.y > 0)
                {
                    m_simpleAnim.CrossFade("JumpStart", 0.1f);
                }
                else if (m_rb.velocity.y < 0)
                {
                    m_simpleAnim.CrossFade("JumpMidAir", 0.1f);
                }
            }
            else
            {
                //if (m_horizontal != 0 || m_virtical != 0)
                //{
                //    if (IsSprint) m_simpleAnim.CrossFade("Sprint", 0.1f);
                //    else m_simpleAnim.CrossFade("Run", 0.1f);

                //    if (LockOnController.IsLock)
                //    {
                //        Debug.Log("居ずロック");
                //        switch (PlayerState.m_PlayerDirState)
                //        {
                //            case PlayerMovingDirection.Neutral:
                //                m_simpleAnim.CrossFade("Default", 0.1f);
                //                break;
                //            case PlayerMovingDirection.Forward:
                //                m_simpleAnim.CrossFade("WalkForward", 0.1f);
                //                Debug.Log("Forward");
                //                break;
                //            case PlayerMovingDirection.Right:
                //                m_simpleAnim.CrossFade("WalkRight", 0.1f);
                //                break;
                //            case PlayerMovingDirection.Left:
                //                m_simpleAnim.CrossFade("WalkLeft", 0.1f);
                //                break;
                //            case PlayerMovingDirection.Back:
                //                m_simpleAnim.CrossFade("WalkBack", 0.1f);
                //                break;
                //            default:
                //                break;
                //        }
                //    }
                //}
                //else if (m_horizontal == 0 && m_virtical == 0) m_simpleAnim.CrossFade("Default", 0.1f);

                Debug.Log($"再生中{m_simpleAnim.IsPlaying("Atack")}");

                switch (PlayerState.m_PlayerDirState)
                {
                case MovingDirection.Neutral:
                    if (m_isAtacking)
                    {
                        m_simpleAnim.CrossFade("Atack", 0.1f);
                    }
                    else
                    {
                        m_simpleAnim.CrossFade("Default", 0.1f);
                    }
                    break;

                case MovingDirection.Move:
                    if (IsSprint)
                    {
                        m_simpleAnim.CrossFade("Sprint", 0.1f);
                    }
                    else
                    {
                        m_simpleAnim.CrossFade("Run", 0.1f);
                    }
                    break;

                case MovingDirection.Forward:
                    m_simpleAnim.CrossFade("WalkForward", 0.1f);
                    break;

                case MovingDirection.Right:
                    m_simpleAnim.CrossFade("WalkRight", 0.1f);
                    break;

                case MovingDirection.Left:
                    m_simpleAnim.CrossFade("WalkLeft", 0.1f);
                    break;

                case MovingDirection.Back:
                    m_simpleAnim.CrossFade("WalkBack", 0.1f);
                    break;

                default:
                    break;
                }
            }
        }
    }