private BasicMotionMatchingJob[] mmJobs; // motion matching job

        public LogicMotionMatchingState(
            MotionMatchingState state,
            MotionMatching component,
            MotionMatchingPlayableGraph playableGraph,
            LogicMotionMatchingLayer logicLayer,
            Transform gameObject,
            int framesForJob
            ) :
            base(state, component, playableGraph, logicLayer, gameObject, framesForJob)
        {
            OnCreate();
        }
Beispiel #2
0
        // Switch State features

        public LogicMotionMatchingLayer(
            MotionMatchingPlayableGraph mmAnimator,
            MotionMatchingLayer layer,
            Transform gameObject
            )
        {
            this.transform       = gameObject;
            passIK               = layer.passIK;
            this.playableGraph   = mmAnimator;
            currentBlendedStates = new List <int>();
            this.layer           = layer;
            logicStates          = new List <LogicState>();
            currentWeights       = new List <float>();


            bestPoseInfo = new NewClipInfoToPlay(-1, -1, -1, -1);
        }
        public void Update(MotionMatchingPlayableGraph graph, bool passIK, bool passFootIK, float deltaTime)
        {
            currentClipTime += deltaTime;

            float seqLocalTime = GetLocalTime();

            for (int i = 0; i < data.clips.Count; i++)
            {
                float currentPlayableTime = GetPlayableTimeInSequenceLocalTime(seqLocalTime, i);
                float currentWeight       = mixer.GetInputWeight(i);
                float desiredWeight       = GetPlayableWeightInPlayableTime(currentPlayableTime, i);

                if (currentWeight <= 0f && desiredWeight > 0f)
                {
                    mixer.GetInput(i).SetTime(currentPlayableTime - Time.deltaTime);
                    mixer.GetInput(i).SetTime(currentPlayableTime);
                }
                mixer.SetInputWeight(i, desiredWeight);
            }
            NormalizeMixerInputWeights();
        }
        public void CreateAnimationsInTime(float time, MotionMatchingPlayableGraph graph, bool passIK, bool passFootIK)
        {
            currentClipTime = time;
            //mixer = AnimationMixerPlayable.Create(graph.graph, 0);
            float seqLocalTime = GetLocalTime();

            for (int i = 0; i < data.clips.Count; i++)
            {
                AnimationClipPlayable playable = AnimationClipPlayable.Create(graph.graph, data.clips[i]);
                playable.SetApplyFootIK(passFootIK);
                playable.SetApplyPlayableIK(passIK);
                mixer.AddInput(playable, 0);

                float currentPlayableTime   = GetPlayableTimeInSequenceLocalTime(seqLocalTime, i);
                float currentplayableWeight = GetPlayableWeightInPlayableTime(currentPlayableTime, i);

                mixer.SetInputWeight(i, currentplayableWeight);
                mixer.GetInput(i).SetTime(currentPlayableTime - Time.deltaTime);
                mixer.GetInput(i).SetTime(currentPlayableTime);
            }
            NormalizeMixerInputWeights();
        }