Example #1
0
        //PlayerController의 DirectionNotifyer 의 Listener.
        public void RotateWeapon(CurrentInput _currentinput)
        {
            if (_currentinput == null)
            {
                return;
            }
            if (_currentinput.fixMove == KeyState.Down)
            {
                if (isFixed)
                {
                    Vector3 m_eulerA = transform.rotation.eulerAngles;
                    if (Mathf.Round(m_eulerA.y) != Mathf.Round(GetComponentInParent <CharacterPhysics>().transform.rotation.eulerAngles.y))
                    {
                        transform.rotation = Mathf.Round(m_eulerA.y) == 0 ? Quaternion.Euler(m_eulerA.x, 180f, m_eulerA.z) : Quaternion.Euler(m_eulerA.x, 0f, m_eulerA.z);
                    }
                }
                else
                {
                    preRotate = transform.rotation;
                }
                isFixed = !isFixed;
            }
            if (isFixed)
            {
                transform.rotation = preRotate;
                return;
            }

            Vector2    _toVector = _currentinput.ToVector();
            Quaternion dir       = new Quaternion();

            if (GetComponentInParent <CharacterPhysics>().onWall)// || GetComponentInParent<CharacterPhysics>().isCrouching)
            {
                dir = Quaternion.Euler(0f, transform.rotation.eulerAngles.y, 0f);
            }
            else
            {
                dir = Quaternion.Euler(0f, transform.rotation.eulerAngles.y, _toVector.x == 0 ? _toVector.y * 90 : _toVector.y * 45);
            }
            transform.rotation = dir;
        }