/// <summary> /// Creates the animator substate machine for this motion. /// </summary> protected override void CreateStateMachine() { // Grab the root sm for the layer UnityEditor.Animations.AnimatorStateMachine lRootStateMachine = _EditorAnimatorController.layers[mMotionLayer.AnimatorLayerIndex].stateMachine; // If we find the sm with our name, remove it for (int i = 0; i < lRootStateMachine.stateMachines.Length; i++) { // Look for a sm with the matching name if (lRootStateMachine.stateMachines[i].stateMachine.name == _EditorAnimatorSMName) { // Allow the user to stop before we remove the sm if (!UnityEditor.EditorUtility.DisplayDialog("Motion Controller", _EditorAnimatorSMName + " already exists. Delete and recreate it?", "Yes", "No")) { return; } // Remove the sm lRootStateMachine.RemoveStateMachine(lRootStateMachine.stateMachines[i].stateMachine); } } UnityEditor.Animations.AnimatorStateMachine lMotionStateMachine = lRootStateMachine.AddStateMachine(_EditorAnimatorSMName); // Attach the behaviour if needed if (_EditorAttachBehaviour) { MotionControllerBehaviour lBehaviour = lMotionStateMachine.AddStateMachineBehaviour(typeof(MotionControllerBehaviour)) as MotionControllerBehaviour; lBehaviour._MotionKey = (_Key.Length > 0 ? _Key : this.GetType().FullName); } UnityEditor.Animations.AnimatorState lIdlePose = lMotionStateMachine.AddState("IdlePose", new Vector3(264, 72, 0)); lIdlePose.motion = mIdlePose; lIdlePose.speed = 1f; UnityEditor.Animations.AnimatorStateTransition lAnyStateTransition = null; // Create the transition from the any state. Note that 'AnyState' transitions have to be added to the root lAnyStateTransition = lRootStateMachine.AddAnyStateTransition(lIdlePose); lAnyStateTransition.hasExitTime = false; lAnyStateTransition.hasFixedDuration = true; lAnyStateTransition.exitTime = 0.8144876f; lAnyStateTransition.duration = 0.01185336f; lAnyStateTransition.offset = 0f; lAnyStateTransition.mute = false; lAnyStateTransition.solo = false; lAnyStateTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 100f, "L0MotionPhase"); }
/// <summary> /// Creates the animator substate machine for this motion. /// </summary> protected override void CreateStateMachine() { // Grab the root sm for the layer UnityEditor.Animations.AnimatorStateMachine lRootStateMachine = _EditorAnimatorController.layers[mMotionLayer.AnimatorLayerIndex].stateMachine; // If we find the sm with our name, remove it for (int i = 0; i < lRootStateMachine.stateMachines.Length; i++) { // Look for a sm with the matching name if (lRootStateMachine.stateMachines[i].stateMachine.name == _EditorAnimatorSMName) { // Allow the user to stop before we remove the sm if (!UnityEditor.EditorUtility.DisplayDialog("Motion Controller", _EditorAnimatorSMName + " already exists. Delete and recreate it?", "Yes", "No")) { return; } // Remove the sm lRootStateMachine.RemoveStateMachine(lRootStateMachine.stateMachines[i].stateMachine); } } UnityEditor.Animations.AnimatorStateMachine lMotionStateMachine = lRootStateMachine.AddStateMachine(_EditorAnimatorSMName); // Attach the behaviour if needed if (_EditorAttachBehaviour) { MotionControllerBehaviour lBehaviour = lMotionStateMachine.AddStateMachineBehaviour(typeof(MotionControllerBehaviour)) as MotionControllerBehaviour; lBehaviour._MotionKey = (_Key.Length > 0 ? _Key : this.GetType().FullName); } UnityEditor.Animations.AnimatorState lIdlePose = lMotionStateMachine.AddState("IdlePose", new Vector3(840, 204, 0)); lIdlePose.motion = mIdlePose; lIdlePose.speed = 1f; UnityEditor.Animations.AnimatorState lRunJump_RunForward = lMotionStateMachine.AddState("RunJump_RunForward", new Vector3(588, 288, 0)); lRunJump_RunForward.motion = mRunForward; lRunJump_RunForward.speed = 1f; UnityEditor.Animations.AnimatorState lRunningJump = lMotionStateMachine.AddState("RunningJump", new Vector3(324, 204, 0)); lRunningJump.motion = mRunningJump; lRunningJump.speed = 1f; UnityEditor.Animations.AnimatorState lLandToIdle = lMotionStateMachine.AddState("LandToIdle", new Vector3(588, 204, 0)); lLandToIdle.motion = mLandToIdle; lLandToIdle.speed = 1f; UnityEditor.Animations.AnimatorStateTransition lAnyStateTransition = null; // Create the transition from the any state. Note that 'AnyState' transitions have to be added to the root lAnyStateTransition = lRootStateMachine.AddAnyStateTransition(lRunningJump); lAnyStateTransition.hasExitTime = false; lAnyStateTransition.hasFixedDuration = true; lAnyStateTransition.exitTime = 0.9f; lAnyStateTransition.duration = 0.05f; lAnyStateTransition.offset = 0f; lAnyStateTransition.mute = false; lAnyStateTransition.solo = false; lAnyStateTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 27500f, "L0MotionPhase"); UnityEditor.Animations.AnimatorStateTransition lStateTransition = null; lStateTransition = lRunningJump.AddTransition(lRunJump_RunForward); lStateTransition.hasExitTime = false; lStateTransition.hasFixedDuration = true; lStateTransition.exitTime = 0.8280886f; lStateTransition.duration = 0.2499999f; lStateTransition.offset = 0.2955611f; lStateTransition.mute = false; lStateTransition.solo = false; lStateTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 27545f, "L0MotionPhase"); lStateTransition = lRunningJump.AddTransition(lLandToIdle); lStateTransition.hasExitTime = false; lStateTransition.hasFixedDuration = true; lStateTransition.exitTime = 0.8032071f; lStateTransition.duration = 0.1951104f; lStateTransition.offset = 0f; lStateTransition.mute = false; lStateTransition.solo = false; lStateTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 27540f, "L0MotionPhase"); lStateTransition = lLandToIdle.AddTransition(lIdlePose); lStateTransition.hasExitTime = true; lStateTransition.hasFixedDuration = true; lStateTransition.exitTime = 0.6590909f; lStateTransition.duration = 0.25f; lStateTransition.offset = 0f; lStateTransition.mute = false; lStateTransition.solo = false; }
/// <summary> /// Creates the animator substate machine for this motion. /// </summary> protected override void CreateStateMachine() { // Grab the root sm for the layer UnityEditor.Animations.AnimatorStateMachine lRootStateMachine = _EditorAnimatorController.layers[mMotionLayer.AnimatorLayerIndex].stateMachine; // If we find the sm with our name, remove it for (int i = 0; i < lRootStateMachine.stateMachines.Length; i++) { // Look for a sm with the matching name if (lRootStateMachine.stateMachines[i].stateMachine.name == _EditorAnimatorSMName) { // Allow the user to stop before we remove the sm if (!UnityEditor.EditorUtility.DisplayDialog("Motion Controller", _EditorAnimatorSMName + " already exists. Delete and recreate it?", "Yes", "No")) { return; } // Remove the sm lRootStateMachine.RemoveStateMachine(lRootStateMachine.stateMachines[i].stateMachine); } } UnityEditor.Animations.AnimatorStateMachine lMotionStateMachine = lRootStateMachine.AddStateMachine(_EditorAnimatorSMName); // Attach the behaviour if needed if (_EditorAttachBehaviour) { MotionControllerBehaviour lBehaviour = lMotionStateMachine.AddStateMachineBehaviour(typeof(MotionControllerBehaviour)) as MotionControllerBehaviour; lBehaviour._MotionKey = (_Key.Length > 0 ? _Key : this.GetType().FullName); } UnityEditor.Animations.AnimatorState lWalkVault_1m = lMotionStateMachine.AddState("WalkVault_1m", new Vector3(348, 12, 0)); lWalkVault_1m.motion = mWalkVault_1m; lWalkVault_1m.speed = 1f; UnityEditor.Animations.AnimatorState lWalkForward = lMotionStateMachine.AddState("WalkForward", new Vector3(600, 12, 0)); lWalkForward.motion = mWalkForward; lWalkForward.speed = 1f; UnityEditor.Animations.AnimatorState lRunVault_1m = lMotionStateMachine.AddState("RunVault_1m", new Vector3(348, 96, 0)); lRunVault_1m.motion = mRunVault_1m; lRunVault_1m.speed = 1f; UnityEditor.Animations.AnimatorState lRunForward = lMotionStateMachine.AddState("RunForward", new Vector3(600, 96, 0)); lRunForward.motion = mRunForward; lRunForward.speed = 1f; UnityEditor.Animations.AnimatorStateTransition lAnyStateTransition = null; // Create the transition from the any state. Note that 'AnyState' transitions have to be added to the root lAnyStateTransition = lRootStateMachine.AddAnyStateTransition(lWalkVault_1m); lAnyStateTransition.hasExitTime = false; lAnyStateTransition.hasFixedDuration = true; lAnyStateTransition.exitTime = 0.9f; lAnyStateTransition.duration = 0.1f; lAnyStateTransition.offset = 0f; lAnyStateTransition.mute = false; lAnyStateTransition.solo = false; lAnyStateTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 1300f, "L0MotionPhase"); // Create the transition from the any state. Note that 'AnyState' transitions have to be added to the root lAnyStateTransition = lRootStateMachine.AddAnyStateTransition(lRunVault_1m); lAnyStateTransition.hasExitTime = false; lAnyStateTransition.hasFixedDuration = true; lAnyStateTransition.exitTime = 0.9f; lAnyStateTransition.duration = 0.1f; lAnyStateTransition.offset = 0f; lAnyStateTransition.mute = false; lAnyStateTransition.solo = false; lAnyStateTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Equals, 1305f, "L0MotionPhase"); UnityEditor.Animations.AnimatorStateTransition lStateTransition = null; lStateTransition = lWalkVault_1m.AddTransition(lWalkForward); lStateTransition.hasExitTime = true; lStateTransition.hasFixedDuration = true; lStateTransition.exitTime = 0.7967739f; lStateTransition.duration = 0.103878f; lStateTransition.offset = 0.0009236346f; lStateTransition.mute = false; lStateTransition.solo = false; lStateTransition = lRunVault_1m.AddTransition(lRunForward); lStateTransition.hasExitTime = true; lStateTransition.hasFixedDuration = true; lStateTransition.exitTime = 0.8584905f; lStateTransition.duration = 0.2499999f; lStateTransition.offset = 0.4060542f; lStateTransition.mute = false; lStateTransition.solo = false; }