Exemplo n.º 1
0
        void Update()
        {
            ProcessTestAnimationKeyPresses();

            m_animSpeed = 1.0f;

            AnimState();

            m_curState = AnimStates.Idle;
            m_turnDir  = TurningType.None;

            m_curPos = this.gameObject.transform.position;

            if (!Mathf.Approximately(m_prevPos.x, m_curPos.x) || !Mathf.Approximately(m_prevPos.z, m_curPos.z))
            {
                //Not the most efficient route, but plot a point based on current facing
                Vector3 nextPoint = m_curPos + (this.gameObject.transform.forward);
                //Then get the distance between prev point and "next" point
                float distPrev = Vector3.Distance(m_prevPos, m_curPos);
                float distNext = Vector3.Distance(nextPoint, m_curPos);
                //if (Vector3.Dot(m_curPos - m_prevPos, Vector3.forward) > 0.0f)
                //If we're moving forward then distance between cur and next should always be less than cur and prev
                if (distNext < distPrev)
                {
                    m_curState = AnimStates.MovingBackward;
                }
                else
                {
                    m_curState = AnimStates.MovingForward;
                }
            }
            //{
            //    m_curState = AnimStates.Moving;
            //}

            //If the last grounded height is > 75% of character height, we're falling
            if (m_lastVertHeight - m_curPos.y > (m_controller.height * 0.75f))
            {
                m_curState = AnimStates.Falling;
            }
            //if (!Mathf.Approximately(m_prevPos.y, m_curPos.y))
            //{
            //    m_curState = AnimStates.Falling;
            //}

            m_prevPos = m_curPos;
        }
Exemplo n.º 2
0
        void Start()
        {
            m_controller    = this.GetComponentInChildren <CharacterController>();
            m_curState      = AnimStates.Idle;
            m_animComponent = this.gameObject.GetComponentInChildren <Animation>();

            m_isDead    = false;
            m_isSitting = false;

            for (int i = 0; i < (int)AnimationType.DEFAULT; i++)
            {
                m_animComponent.AddClip(characterAnimations[i], ((AnimationType)i).ToString());
            }

            m_animComponent.Play(characterAnimations[(int)AnimationType.Idle].name);

            m_animComponent.wrapMode = WrapMode.Loop;

            m_attackType = AnimAttackType.None;
            m_turnDir    = TurningType.None;
        }
Exemplo n.º 3
0
        public void CharTurning(bool clockwise)
        {
            if (m_isCrouching)
            {
                return;
            }

            // zer0sum: dont play turn anim if we're running...
            // if (Input.GetKey(KeyCode.W) || (Input.GetMouseButton(0) && Input.GetMouseButtonDown(1)))
            if (m_curState == AnimStates.MovingForward || m_curState == AnimStates.MovingSideWays || m_curState == AnimStates.MovingBackward)
            {
                return;
            }

            m_curState = AnimStates.Turning;
            if (clockwise)
            {
                m_turnDir = TurningType.ClockWise;
            }
            else
            {
                m_turnDir = TurningType.CClockWise;
            }
        }
Exemplo n.º 4
0
        void Update()
        {
            ProcessTestAnimationKeyPresses();

            m_animSpeed = 1.0f;

            AnimState();

            m_curState = AnimStates.Idle;
            m_turnDir = TurningType.None;

            m_curPos = this.gameObject.transform.position;

            if (!Mathf.Approximately(m_prevPos.x, m_curPos.x) || !Mathf.Approximately(m_prevPos.z, m_curPos.z))
            {
                //Not the most efficient route, but plot a point based on current facing
                Vector3 nextPoint = m_curPos + (this.gameObject.transform.forward);
                //Then get the distance between prev point and "next" point
                float distPrev = Vector3.Distance(m_prevPos, m_curPos);
                float distNext = Vector3.Distance(nextPoint, m_curPos);
                //if (Vector3.Dot(m_curPos - m_prevPos, Vector3.forward) > 0.0f)
                //If we're moving forward then distance between cur and next should always be less than cur and prev
                if(distNext < distPrev)
                {
                    m_curState = AnimStates.MovingBackward;
                }
                else
                {
                    m_curState = AnimStates.MovingForward;
                }
            }
            //{
            //    m_curState = AnimStates.Moving;
            //}

            //If the last grounded height is > 75% of character height, we're falling
            if (m_lastVertHeight - m_curPos.y > (m_controller.height * 0.75f))
            {
                m_curState = AnimStates.Falling;
            }
            //if (!Mathf.Approximately(m_prevPos.y, m_curPos.y))
            //{
            //    m_curState = AnimStates.Falling;
            //}

            m_prevPos = m_curPos;
        }
Exemplo n.º 5
0
        void Start()
        {
            m_controller = this.GetComponentInChildren<CharacterController>();
            m_curState = AnimStates.Idle;
            m_animComponent = this.gameObject.GetComponentInChildren<Animation>();

            m_isDead = false;
            m_isSitting = false;

            for (int i = 0; i < (int)AnimationType.DEFAULT; i++)
            {
                m_animComponent.AddClip(characterAnimations[i], ((AnimationType)i).ToString());
            }

            m_animComponent.Play(characterAnimations[(int)AnimationType.Idle].name);

            m_animComponent.wrapMode = WrapMode.Loop;

            m_attackType = AnimAttackType.None;
            m_turnDir = TurningType.None;
        }
Exemplo n.º 6
0
        public void CharTurning(bool clockwise)
        {
            if (m_isCrouching)
                return;

               // zer0sum: dont play turn anim if we're running...
               // if (Input.GetKey(KeyCode.W) || (Input.GetMouseButton(0) && Input.GetMouseButtonDown(1)))
            if (m_curState == AnimStates.MovingForward || m_curState == AnimStates.MovingSideWays || m_curState == AnimStates.MovingBackward)
                return;

            m_curState = AnimStates.Turning;
            if (clockwise)
            {
                m_turnDir = TurningType.ClockWise;
            }
            else
            {
                m_turnDir = TurningType.CClockWise;
            }
        }
Exemplo n.º 7
0
 private void SetTurningType(TurningType type, float add = 0f)
 {
     turningType = type;
     addAngle    = add;
 }