/** * Find the first animator up the hierarchy of the cloth, and get its ObiAnimatorController component or add one if it is not present. */ private void SetupAnimatorController(){ // find the first animator up our hierarchy: Animator animator = GetComponentInParent<Animator>(); // if we have an animator above us, see if it has an animator controller component and add one if it doesn't: if (animator != null){ animatorController = animator.GetComponent<ObiAnimatorController>(); if (animatorController == null) animatorController = animator.gameObject.AddComponent<ObiAnimatorController>(); } }
void Start() { Physics.IgnoreLayerCollision(LayerMask.NameToLayer("Default"), LayerMask.NameToLayer("Ignore Raycast"), true); m_Animator = GetComponent <Animator>(); m_AnimatorController = GetComponent <ObiAnimatorController>(); m_Rigidbody = GetComponent <Rigidbody>(); m_Capsule = GetComponent <CapsuleCollider>(); m_CapsuleHeight = m_Capsule.height; m_CapsuleCenter = m_Capsule.center; m_Rigidbody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ; m_OrigGroundCheckDistance = m_GroundCheckDistance; }