//=========================================================================================== /** * @brief Monobehaviour awak function. Ensures all references are setup before updating * *********************************************************************************************/ public virtual void Awake() { if (m_charController == null) m_charController = GetComponentInChildren<GenericControllerWrapper>(); m_decoupler = m_charController.GetComponent<MxMAnimationDecoupler>(); MxMAnimator mxmAnimator = GetComponent<MxMAnimator>(); if (mxmAnimator.AnimationRoot != null) { m_rootTransform = mxmAnimator.AnimationRoot; if (m_charController == null) { m_charController = m_rootTransform.GetComponent<GenericControllerWrapper>(); } } else { m_rootTransform = transform; } if (m_charController == null) { Debug.LogWarning("Attached Generic Controller Wrapper is null. " + "Root motion will be applied directly to transform"); } }
private void Awake() { m_trajectoryGenerator = GetComponentInChildren <MyTrajectoryGenerator>(); m_animDecoupler = GetComponent <MxMAnimationDecoupler>(); m_charController = GetComponent <GenericControllerWrapper>(); _wrapper = GetComponent <KinematicControllerWrapper>(); if (m_trajectoryGenerator == null) { Debug.LogError("ExampleDecoupleMovementControl cannot find a trajectory generator component. Disabling component"); enabled = false; return; } if (m_animDecoupler == null) { Debug.LogError("ExampleDecoupleMovementControl cannot find a MxMAnimationDecoupler component. Disabling component"); enabled = false; return; } if (m_charController == null) { Debug.LogError("ExampleDecoupleMovementControl canno find a GenericControllerWrapper component. Disabling component"); enabled = false; return; } }
private void Start() { m_maxDecouple = Mathf.Clamp(Mathf.Abs(m_maxDecouple), 0f, float.MaxValue); m_controllerWrapper = GetComponent<GenericControllerWrapper>(); m_mxmAnimator = GetComponentInChildren<MxMAnimator>(); if(m_mxmAnimator != null) { m_modelTransform = m_mxmAnimator.transform; m_animator = m_mxmAnimator.GetComponent<Animator>(); } else { Debug.LogError("MxMAnimationDecoupler: Cannot find child component with MxMAnimator attached. Decoupler disabled"); enabled = false; } Animator animator = GetComponentInChildren<Animator>(); if(animator != null) { if (animator.updateMode == AnimatorUpdateMode.AnimatePhysics) m_fixedUpdate = true; else m_fixedUpdate = false; } else { Debug.LogError("MxMAnimationDecoupler: Cannot find child component with Animator attached. Decoupler disabled"); enabled = false; } m_modelPos = m_modelTransform.position; m_modelRot = m_modelTransform.rotation; }