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(); }
public void RemoveZeroWeightsInputFromLayer( LogicMotionMatchingLayer layer, List <int> currentBlendedStates, List <float> blendingWeights, List <float> currentWeights ) { int size = layer.mixer.GetInputCount(); for (int inputIndex_1 = 0; inputIndex_1 < size; inputIndex_1++) { float weight = layer.mixer.GetInputWeight(inputIndex_1); if (weight <= 0f) { int mixerInputs = (layer.mixer.GetInput(inputIndex_1).GetInputCount()); if (mixerInputs == 0) { layer.mixer.GetInput(inputIndex_1).Destroy(); } else { for (int dataMixerIndex = 0; dataMixerIndex < mixerInputs; dataMixerIndex++) { layer.mixer.GetInput(inputIndex_1).GetInput(dataMixerIndex).Destroy(); } layer.mixer.GetInput(inputIndex_1).Destroy(); } blendingWeights.RemoveAt(inputIndex_1); currentWeights.RemoveAt(inputIndex_1); layer.logicStates[currentBlendedStates[inputIndex_1]].StateExit(); currentBlendedStates.RemoveAt(inputIndex_1); for (int inputIndex_2 = inputIndex_1 + 1; inputIndex_2 < size; inputIndex_2++) { float _weight = layer.mixer.GetInputWeight(inputIndex_2); AnimationMixerPlayable switchedMixer = (AnimationMixerPlayable)layer.mixer.GetInput(inputIndex_2); layer.mixer.DisconnectInput(inputIndex_2); layer.mixer.ConnectInput(inputIndex_2 - 1, switchedMixer, 0); layer.mixer.SetInputWeight(inputIndex_2 - 1, _weight); } inputIndex_1--; size--; layer.mixer.SetInputCount(size); } } }
// For logic state public void AddStatePlayable(LogicState state, LogicMotionMatchingLayer layer) { state.SetPlayable(AnimationMixerPlayable.Create(this.graph)); layer.GetPlayable().AddInput(state.GetPlayable(), 0); }
// For Logic layer public void AddLayerPlayable(LogicMotionMatchingLayer layer) { layer.SetPlayable(AnimationMixerPlayable.Create(this.graph, 0, true)); layerMixer.AddInput(layer.GetPlayable(), 0, 1f); }