void Start() { m_animator = GetComponent <MxMAnimator>(); trajectoryGenerator = GetComponent <MxMTrajectoryGenerator_BasicAI>(); //m_animator.SetRequiredTag("Locomotion"); sit = false; strafe = false; oneTime = false; }
private void Start() { m_mxmAnimator = m_playerTransform.GetComponentInChildren <MxMAnimator>(); m_trajectoryGenerator = m_playerTransform.GetComponentInChildren <MxMTrajectoryGenerator>(); m_runTagHandle = m_mxmAnimator.CurrentAnimData.FavourTagFromName(m_runSpeedTagName); m_sprintTagHandle = m_mxmAnimator.CurrentAnimData.FavourTagFromName(m_sprintSpeedTagName); m_mxmAnimator.SetFavourMultiplier(m_favourMultiplier); }
// Start is called before the first frame update void Start() { m_mxmAnimator = GetComponent <MxMAnimator>(); m_controller = GetComponent <CharacterController>(); m_trajectoryGenerator = GetComponent <MxMTrajectoryGenerator>(); m_rootMotionAplicator = GetComponent <MxMRootMotionApplicator>(); m_vaultDetector = GetComponent <VaultDetector>(); m_locomotionSpeedRamp = GetComponent <LocomotionSpeedRamp>(); m_defaultControllerHeight = m_controller.height; m_defaultControllerCenter = m_controller.center.y; m_controller.enableOverlapRecovery = true; m_trajectoryGenerator.InputProfile = m_generalLocomotion; }
private void SpawnIdentical() { Vector3 basePosition = transform.position; for (int row = 0; row < Rows; ++row) { for (int col = 0; col < Cols; ++col) { GameObject newSpawn = Instantiate(SpawnPrefab); newSpawn.transform.position = new Vector3(12.3f, 0f, 17f) - new Vector3(Rows * Spacing / 2f, 0f, Cols * Spacing / 2f) + new Vector3(row * Spacing, 0f, col * Spacing); newSpawn.SetActive(true); MxMAnimator animator = newSpawn.GetComponent <MxMAnimator>(); animator.UpdateInterval = UpdateIntervalSlider.value; m_actors.Add(animator); } } }
//=========================================================================================== /** * Here you will need to get handles to the root transform. You can also do any other awake * logic you might need. * *********************************************************************************************/ public void Awake() { //Get the MxMAnimator component. You can do this in anyway. We just need it to get the //root transform override that the MxMAnimator is using MxMAnimator mxmAnimator = GetComponent<MxMAnimator>(); if (mxmAnimator.AnimationRoot != null) { //Set the root transform to that of the MxMAnimator AnimationRoot property m_rootTransform = mxmAnimator.AnimationRoot; } else { //If the MxMAnimator doesn't have a root transform then we default to the transform //that this component is placed on. m_rootTransform = transform; } //Your custom awake logic goes here }
//============================================================================================ /** * @brief * *********************************************************************************************/ private void OnEnable() { m_animator = target as MxMAnimator; m_spDIYPlayableGraph = serializedObject.FindProperty("p_DIYPlayableGraph"); m_spAutoCreateAnimatorController = serializedObject.FindProperty("m_autoCreateAnimatorController"); m_spAnimatorControllerMask = serializedObject.FindProperty("m_animatorControllerMask"); m_spRootMotionMode = serializedObject.FindProperty("m_rootMotionMode"); m_spTransitionMethod = serializedObject.FindProperty("m_transitionMethod"); m_spUpdateInterval = serializedObject.FindProperty("m_updateInterval"); m_spPlaybackSpeed = serializedObject.FindProperty("m_playbackSpeed"); m_spPlaybackSpeedSmoothRate = serializedObject.FindProperty("m_playbackSpeedSmoothRate"); m_spMatchBlendTime = serializedObject.FindProperty("m_matchBlendTime"); m_spTurnInPlaceThreshold = serializedObject.FindProperty("m_turnInPlaceThreshold"); m_spAnimData = serializedObject.FindProperty("m_animData"); m_spAnimationRootOverride = serializedObject.FindProperty("m_animationRoot"); m_spMaxMixCount = serializedObject.FindProperty("m_maxMixCount"); m_spDebugGoal = serializedObject.FindProperty("m_debugGoal"); m_spDebugChosenTrajectory = serializedObject.FindProperty("m_debugChosenTrajectory"); m_spDebugPoses = serializedObject.FindProperty("m_debugPoses"); m_spDebugCurrentPose = serializedObject.FindProperty("m_debugCurrentPose"); m_spDebugAnimDataId = serializedObject.FindProperty("m_debugAnimDataId"); m_spDebugPoseId = serializedObject.FindProperty("m_debugPoseId"); m_spAngularWarpType = serializedObject.FindProperty("m_angularWarpType"); m_spAngularWarpMethod = serializedObject.FindProperty("m_angularWarpMethod"); m_spLongErrorWarpType = serializedObject.FindProperty("m_longErrorWarpType"); m_spSpeedWarpLimits = serializedObject.FindProperty("m_speedWarpLimits"); m_spBlendOutEarly = serializedObject.FindProperty("m_blendOutEarly"); m_spPoseMatchMethod = serializedObject.FindProperty("m_poseMatchMethod"); m_spFavourTagMethod = serializedObject.FindProperty("m_favourTagMethod"); m_spPastTrajectoryMode = serializedObject.FindProperty("m_pastTrajectoryMode"); m_spAngularErrorWarpRate = serializedObject.FindProperty("m_angularErrorWarpRate"); m_spAngularErrorWarpThreshold = serializedObject.FindProperty("m_angularErrorWarpThreshold"); m_spAngularErrorWarpAngleThreshold = serializedObject.FindProperty("m_angularErrorWarpAngleThreshold"); m_spAngularErrorWarpMinAngleThreshold = serializedObject.FindProperty("m_angularErrorWarpMinAngleThreshold"); m_spApplyTrajectoryBlending = serializedObject.FindProperty("m_applyTrajectoryBlending"); m_spTrajectoryBlendingWeight = serializedObject.FindProperty("m_trajectoryBlendingWeight"); m_spFavourCurrentPose = serializedObject.FindProperty("m_favourCurrentPose"); m_spTransformGoal = serializedObject.FindProperty("m_transformGoal"); m_spPoseFavourFactor = serializedObject.FindProperty("m_currentPoseFavour"); m_spBlendSpaceSmoothing = serializedObject.FindProperty("m_blendSpaceSmoothing"); m_spBlendSpaceSmoothRate = serializedObject.FindProperty("m_blendSpaceSmoothRate"); m_spNextPoseToleranceTest = serializedObject.FindProperty("m_nextPoseToleranceTest"); m_spNextPoseToleranceDist = serializedObject.FindProperty("m_nextPoseToleranceDist"); m_spNextPoseToleranceAngle = serializedObject.FindProperty("m_nextPoseToleranceAngle"); m_spOnSetupCompleteCallback = serializedObject.FindProperty("m_onSetupComplete"); m_spOnIdleTriggeredCallback = serializedObject.FindProperty("m_onIdleTriggered"); m_spOnLeftFootStepStartCallback = serializedObject.FindProperty("m_onLeftFootStepStart"); m_spOnRightFootStepStartCallback = serializedObject.FindProperty("m_onRightFootStepStart"); m_spOnEventCompleteCallback = serializedObject.FindProperty("m_onEventComplete"); m_spOnEventContactCallback = serializedObject.FindProperty("m_onEventContactReached"); m_spOnEventChangeStateCallback = serializedObject.FindProperty("m_onEventStateChanged"); m_spGeneralFoldout = serializedObject.FindProperty("m_generalFoldout"); m_spAnimDataFoldout = serializedObject.FindProperty("m_animDataFoldout"); m_spOptionsFoldout = serializedObject.FindProperty("m_optionsFoldout"); m_spWarpingFoldout = serializedObject.FindProperty("m_warpingFoldout"); m_spCallbackFoldout = serializedObject.FindProperty("m_debugFoldout"); m_spDebugFoldout = serializedObject.FindProperty("m_callbackFoldout"); if (m_spAnimData.arraySize == 0) m_spAnimData.InsertArrayElementAtIndex(0); if (m_spAnimData.arraySize > 0) { SerializedProperty spAnimData = m_spAnimData.GetArrayElementAtIndex(0); if (spAnimData != null) { m_animData = m_spAnimData.GetArrayElementAtIndex(0).objectReferenceValue as MxMAnimData; } } if (m_spDebugPoses.boolValue) m_animator.StartPoseDebug(m_spDebugAnimDataId.intValue); m_animDataReorderableList = new ReorderableList(serializedObject, m_spAnimData, true, true, true, true); m_animDataReorderableList.drawElementCallback = (Rect a_rect, int a_index, bool a_isActive, bool a_isFocused) => { var element = m_animDataReorderableList.serializedProperty.GetArrayElementAtIndex(a_index); EditorGUI.LabelField(new Rect(a_rect.x, a_rect.y, 100f, EditorGUIUtility.singleLineHeight), "Anim Data " + (a_index + 1).ToString()); EditorGUI.ObjectField(new Rect(a_rect.x + 100f, a_rect.y, EditorGUIUtility.currentViewWidth - 170f, EditorGUIUtility.singleLineHeight), element, new GUIContent("")); }; m_animDataReorderableList.drawHeaderCallback = (Rect a_rect) => { EditorGUI.LabelField(a_rect, "Anim Data"); }; m_animDataReorderableList.onRemoveCallback = (ReorderableList a_list) => { if(a_list.index >= 0 && a_list.index < a_list.serializedProperty.arraySize) { SerializedProperty spObject = a_list.serializedProperty.GetArrayElementAtIndex(a_list.index); if(spObject.objectReferenceValue != null) { spObject.objectReferenceValue = null; } } ReorderableList.defaultBehaviours.DoRemoveButton(a_list); }; serializedObject.ApplyModifiedProperties(); if(EditorApplication.isPlaying) SetDebuggerTarget(); EditorApplication.playModeStateChanged += OnPlayModeStateChanged; }
public void Awake() { if (m_vaultConfigurations == null || m_vaultConfigurations.Length == 0) { Debug.LogError("VaultDetector: Trying to Awake Vault Detector with null or empty vault configurations (m_vaultConfiguration)"); Destroy(this); return; } if (m_vaultDefinitions == null || m_vaultDefinitions.Length == 0) { Debug.LogError("VaultDetector: Trying to Awake Vault Detector with null or empty vault definitions (m_vaultDefinitions)"); Destroy(this); return; } m_mxmAnimator = GetComponentInChildren <MxMAnimator>(); if (m_mxmAnimator == null) { Debug.LogError("VaultDetector: Trying to Awake Vault Detector but the MxMAnimator component cannot be found"); Destroy(this); return; } m_trajectoryGenerator = GetComponentInChildren <MxMTrajectoryGenerator>(); if (m_trajectoryGenerator == null) { Debug.LogError("VaultDetector: Trying to Awake Vault Detector but there is no Trajectory component found that implements IMxMTrajectory."); Destroy(this); return; } m_rootMotionApplicator = GetComponentInChildren <MxMRootMotionApplicator>(); m_controllerWrapper = GetComponentInChildren <GenericControllerWrapper>(); m_minVaultRise = float.MaxValue; m_maxVaultRise = float.MinValue; m_minVaultDepth = float.MaxValue; m_maxVaultDepth = float.MinValue; m_minVaultDrop = float.MaxValue; m_maxVaultDrop = float.MinValue; foreach (VaultDefinition vd in m_vaultDefinitions) { switch (vd.VaultType) { case EVaultType.StepUp: { if (vd.MinRise < m_minVaultRise) { m_minVaultRise = vd.MinRise; } if (vd.MaxRise > m_maxVaultRise) { m_maxVaultRise = vd.MaxRise; } if (vd.MinDepth < m_minVaultDepth) { m_minVaultDepth = vd.MinDepth; } } break; case EVaultType.StepOver: { if (vd.MinRise < m_minVaultRise) { m_minVaultRise = vd.MinRise; } if (vd.MaxRise > m_maxVaultRise) { m_maxVaultRise = vd.MaxRise; } if (vd.MinDepth < m_minVaultDepth) { m_minVaultDepth = vd.MinDepth; } if (vd.MaxDepth > m_maxVaultDepth) { m_maxVaultDepth = vd.MaxDepth; } } break; case EVaultType.StepOff: { if (vd.MinDepth < m_minVaultDepth) { m_minVaultDepth = vd.MinDepth; } if (vd.MinDrop < m_minVaultDrop) { m_minVaultDrop = vd.MinDrop; } if (vd.MaxDrop > m_maxVaultDrop) { m_maxVaultDrop = vd.MaxDrop; } } break; } } m_curConfig = m_vaultConfigurations[0]; DesiredAdvance = Advance = 0f; m_vaultAnalysisIterations = (int)(m_maxVaultDepth / m_curConfig.ShapeAnalysisSpacing) + 1; }
// Start is called before the first frame update void Start() { m_mxmAnimator = GetComponentInChildren <MxMAnimator>(); m_locomotionSpeedRamp = GetComponentInChildren <LocomotionSpeedRamp>(); }