コード例 #1
0
    void InvokeIdleSecondIncrement()
    {
        m_animator.applyRootMotion = true;
        GameObject t_hybrid1 = gameObject;

        //if (m_flip)
        //{
        //    t_hybrid1.transform.position = new Vector3(1, 0, 0);
        //}
        //else
        //{
        //    t_hybrid1.transform.position = new Vector3(-1, 0, 0);
        //}
        m_between1_1 = m_animIdle.GetIdleIdleHash();
        SaveKeyFramesBetween1_1();
        m_between1_1 = m_animIdle.GetIdleInbetweenTwoOne();
        SaveKeyFramesBetween1_1();
        m_between1_1 = m_animIdle.GetIdleInbetweenOneOne();
        SaveKeyFramesBetween1_1();
        m_between1_1 = m_animIdle.GetIdleInbetweenTwoTwo();
        SaveKeyFramesBetween1_1();
        m_between1_1 = m_animIdle.GetExtendHash();
        SaveKeyFramesBetween1_1();
    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        if (prevClip != activeClip)
        {
            loadAnims = true;
            m_sync    = true;
        }

        m_prevTrans   = m_transition;
        m_transition += Time.deltaTime / m_timeAdjuster;
        //print(m_transition);///// PRINTHÄR asdasdsaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
        if (m_transition > 1.0f)
        {
            m_transition -= 1.0f;
        }

        if (m_prevFramesToAdd != m_framesToAdd && !m_sync)
        {
            //GameObject t_hybrid1 = GameObject.Find("HybridAnimation");
            //GameObject t_original1 = GameObject.Find("OriginalAnimation");
            //if (m_flip)
            //{
            //    t_hybrid1.transform.position = new Vector3(1, 0, 0);
            //    t_original1.transform.position = new Vector3(-1, 0, 0);
            //}
            //else
            //{
            //    t_hybrid1.transform.position = new Vector3(-1, 0, 0);
            //    t_original1.transform.position = new Vector3(1, 0, 0);
            //}
            switch (activeClip)
            {
            case AnimationClips.Idle:
                poses.Clear();
                hipspos.Clear();
                m_animIdle.ResetSwitch();
                m_animator.applyRootMotion = true;
                if (m_framesToAdd == 0)
                {
                    SaveKeyFramesWalkFWD0();
                    SaveKeyFramesWalkFWD2();
                }
                else if (m_framesToAdd == 1)
                {
                    SaveKeyFramesWalkFWD0();
                    SaveKeyFramesIdleBetween1_1();
                    SaveKeyFramesWalkFWD2();
                }
                else if (m_framesToAdd == 2)
                {
                    SaveKeyFramesWalkFWD0();
                    SaveKeyFramesIdleBetween2_1();
                    SaveKeyFramesIdleBetween1_1();
                    SaveKeyFramesIdleBetween2_2();
                    SaveKeyFramesWalkFWD2();
                }
                m_animIdle.ChangeKeyFrames(m_framesToAdd);
                m_timeAdjuster = m_animIdle.timeAdjuster;
                break;

            case AnimationClips.Crouching:
                poses.Clear();
                hipspos.Clear();
                m_animator.applyRootMotion = false;
                if (m_framesToAdd == 0)
                {
                    SaveKeyFramesCrouching();
                    SaveKeyFramesStanding();
                    deltaTimeIncreaser = 0.7f;     // 0.86
                }
                else if (m_framesToAdd == 2)
                {
                    SaveKeyFramesCrouching();
                    m_between1_1 = Animator.StringToHash("Crouching_2_1");
                    SaveKeyFramesBetween1_1();
                    m_between1_1 = Animator.StringToHash("Crouching_1_1");
                    SaveKeyFramesBetween1_1();
                    m_between1_1 = Animator.StringToHash("Crouching_2_2");
                    SaveKeyFramesBetween1_1();
                    SaveKeyFramesStanding();
                    deltaTimeIncreaser = 0.7f;
                }
                else if (m_framesToAdd == 1)
                {
                    SaveKeyFramesCrouching();
                    m_between1_1 = Animator.StringToHash("Crouching_1_1");
                    SaveKeyFramesBetween1_1();
                    SaveKeyFramesStanding();
                    deltaTimeIncreaser = 0.7f;
                }
                break;

            case AnimationClips.Walking:
                poses.Clear();
                hipspos.Clear();
                m_animator.applyRootMotion = false;
                if (m_framesToAdd == 0)
                {
                    SaveKeyFramesWalkFWD0();
                    SaveKeyFramesWalkFWD1();
                    SaveKeyFramesWalkFWD2();
                    SaveKeyFramesWalkFWD3();
                }
                else if (m_framesToAdd == 1)
                {
                    SaveKeyFramesWalkFWD0();
                    m_between1_1 = Animator.StringToHash("WalkFWD_Extend1_1");
                    SaveKeyFramesBetween1_1();
                    SaveKeyFramesWalkFWD1();
                    m_between1_1 = Animator.StringToHash("WalkFWD_Cross1_1");
                    SaveKeyFramesBetween1_1();
                    SaveKeyFramesWalkFWD2();
                    m_between1_1 = Animator.StringToHash("WalkFWD_Extend_Mirror1_1");
                    SaveKeyFramesBetween1_1();
                    SaveKeyFramesWalkFWD3();
                    m_between1_1 = Animator.StringToHash("WalkFWD_Cross_Mirror1_1");
                    SaveKeyFramesBetween1_1();
                }
                else if (m_framesToAdd == 2)
                {
                    InvokeWalkSecondIncrement();
                }
                break;

            case AnimationClips.Runnning:
                poses.Clear();
                hipspos.Clear();
                m_animator.applyRootMotion = false;
                if (m_framesToAdd == 0)
                {
                    //SaveKeyFramesWalkFWD0();
                    //SaveKeyFramesWalkFWD1();
                    //SaveKeyFramesWalkFWD2();
                    //SaveKeyFramesWalkFWD3();

                    m_between1_1 = Animator.StringToHash("1");
                    SaveKeyFramesBetween1_1();
                    m_between1_1 = Animator.StringToHash("3");
                    SaveKeyFramesBetween1_1();
                    m_between1_1 = Animator.StringToHash("5");
                    SaveKeyFramesBetween1_1();
                    m_between1_1 = Animator.StringToHash("7");
                    SaveKeyFramesBetween1_1();
                }
                else if (m_framesToAdd == 1)
                {
                    m_between1_1 = Animator.StringToHash("1");
                    SaveKeyFramesBetween1_1();
                    m_between1_1 = Animator.StringToHash("2");
                    SaveKeyFramesBetween1_1();
                    m_between1_1 = Animator.StringToHash("3");
                    SaveKeyFramesBetween1_1();
                    m_between1_1 = Animator.StringToHash("4");
                    SaveKeyFramesBetween1_1();
                    m_between1_1 = Animator.StringToHash("5");
                    SaveKeyFramesBetween1_1();
                    m_between1_1 = Animator.StringToHash("6");
                    SaveKeyFramesBetween1_1();
                    m_between1_1 = Animator.StringToHash("7");
                    SaveKeyFramesBetween1_1();
                    m_between1_1 = Animator.StringToHash("8");
                    SaveKeyFramesBetween1_1();
                }
                break;

            default:
                break;
            }
            m_transition = 0;
            m_prevTrans  = 0;
        }
        if (loadAnims)
        {
            poses.Clear();
            hipspos.Clear();
            switch (activeClip)
            {
            case AnimationClips.Walking:
                m_extendHash               = m_animWalk.GetExtendHash();
                m_extendMirrorHash         = m_animWalk.GetExtendMirrorHash();
                m_crossHash                = m_animWalk.GetCrossHash();
                m_crossMirrorHash          = m_animWalk.GetCrossMirrorHash();
                m_animator.applyRootMotion = false;
                if (m_framesToAdd == 0)
                {
                    InvokeKeyFramesWalkingFWD();
                }
                else if (m_framesToAdd == 1)
                {
                    Invoke("InvokeWalkFirstIncrement", 0.25f);
                }
                else if (m_framesToAdd == 2)
                {
                    Invoke("InvokeWalkSecondIncrement", 0.25f);
                }
                m_timeAdjuster = m_animWalk.timeAdjuster;
                break;

            case AnimationClips.Runnning:
                m_extendHash               = m_animRun.GetExtendHash();
                m_extendMirrorHash         = m_animRun.GetExtendMirrorHash();
                m_crossHash                = m_animRun.GetCrossHash();
                m_crossMirrorHash          = m_animRun.GetCrossMirrorHash();
                m_animator.applyRootMotion = false;
                if (m_framesToAdd == 0)
                {
                    //InvokeKeyFramesWalkingFWD();
                    Invoke("InvokeRunNoIncrement", 0.25f);
                }
                else if (m_framesToAdd == 1)
                {
                    Invoke("InvokeRunFirstIncrement", 0.25f);
                }
                m_timeAdjuster = m_animRun.timeAdjuster;
                break;

            case AnimationClips.Crouching:
                m_animator.applyRootMotion = false;
                if (m_framesToAdd == 0)
                {
                    Invoke("SaveKeyFramesCrouching", 0.25f);
                    Invoke("SaveKeyFramesStanding", 0.5f);
                    deltaTimeIncreaser = 0.86f;
                }
                else if (m_framesToAdd == 1)
                {
                    Invoke("InvokeCrouchFirstIncrement", 0.25f);
                    deltaTimeIncreaser = 0.7f;
                }

                else if (m_framesToAdd == 2)
                {
                    Invoke("InvokeCrouchSecondIncrement", 0.25f);
                    deltaTimeIncreaser = 0.7f;
                }
                m_timeAdjuster = m_animDuck.timeAdjuster;
                break;

            case AnimationClips.Idle:
                m_extendHash       = m_animIdle.GetIdleIdleHash();
                m_extendMirrorHash = m_animIdle.GetExtendHash();
                m_between1_1       = m_animIdle.GetIdleInbetweenOneOne();
                m_between2_1       = m_animIdle.GetIdleInbetweenTwoOne();
                m_between2_2       = m_animIdle.GetIdleInbetweenTwoTwo();
                m_animIdle.ResetSwitch();
                if (m_framesToAdd == 0)
                {
                    Invoke("InvokeIdleNoIncrement", 0.25f);
                }
                else if (m_framesToAdd == 1)
                {
                    Invoke("InvokeIdleFirstIncrement", 0.25f);
                }
                else if (m_framesToAdd == 2)
                {
                    Invoke("InvokeIdleSecondIncrement", 0.25f);
                }
                m_timeAdjuster = m_animIdle.timeAdjuster;
                m_animIdle.ChangeKeyFrames(m_framesToAdd);
                break;

            default:
                break;
            }
            loadAnims    = false;
            m_transition = 0;
            m_prevTrans  = 0;
        }
        switch (activeClip)
        {
        case AnimationClips.Walking:
            if (poses.Count > 3 + m_framesToAdd)
            {
                m_animWalk.WalkingUpdate(m_transition, m_prevTrans, poses, hipspos, headBob, gameObject);    //UpdateAnimationASD();
            }
            break;

        case AnimationClips.Runnning:
            if (poses.Count > 3)
            {
                m_animRun.RunningUpdate(m_transition, m_prevTrans, poses, hipspos, headBob, gameObject);//UpdateAnimationASD();
            }
            break;

        case AnimationClips.Crouching:
            if (poses.Count > 1)
            {
                m_animDuck.UpdateAnimation(m_transition, poses, hipspos, deltaTimeIncreaser, angularVelo, damper);
            }
            break;

        case AnimationClips.Idle:
            if (poses.Count > 1 + m_framesToAdd)
            {
                m_animIdle.IdleUpdate(m_transition, m_prevTrans, poses, hipspos, headBob, gameObject);
            }
            break;

        default:
            break;
        }
        //GameObject t_hybrid = GameObject.Find("HybridAnimation");
        // GameObject t_original = GameObject.Find("OriginalAnimation");
        if (m_flip)
        {
            //t_hybrid.transform.position = new Vector3(1, 0, 0);
            //t_original.transform.position = new Vector3(-1, 0, 0);
        }
        else
        {
            //t_hybrid.transform.position = new Vector3(-1, 0, 0);
            //t_original.transform.position = new Vector3(1, 0, 0);
        }
        prevClip          = activeClip;
        m_prevFramesToAdd = m_framesToAdd;
    }