private void Awake() { //Get Movement Controller. warriorMovementController = GetComponent <WarriorMovementControllerFREE>(); //Add Input and Timing Controllers. warriorInputController = gameObject.AddComponent <WarriorInputControllerFREE>(); warriorTiming = gameObject.AddComponent <WarriorTimingFREE>(); warriorTiming.warriorController = this; //Add IKHands. ikHands = GetComponent <IKHands>(); //Setup Animator, add AnimationEvents script. animator = GetComponentInChildren <Animator>(); if (animator == null) { Debug.LogError("ERROR: There is no Animator component for character."); Destroy(this); } else { animator.gameObject.AddComponent <WarriorCharacterAnimatorEvents>(); animator.GetComponent <WarriorCharacterAnimatorEvents>().warriorController = this; animator.gameObject.AddComponent <AnimatorParentMove>(); animator.GetComponent <AnimatorParentMove>().anim = animator; animator.GetComponent <AnimatorParentMove>().warriorMovementController = warriorMovementController; animator.updateMode = AnimatorUpdateMode.AnimatePhysics; animator.cullingMode = AnimatorCullingMode.CullUpdateTransforms; } leftHandTrans = transform.Find("ArrowSpawn"); }
private void Awake() { // Get SuperCharacterController. superCharacterController = GetComponent <SuperCharacterController>(); // Get Movement Controller. warriorMovementController = GetComponent <WarriorMovementController>(); // Add Timing Controllers. warriorTiming = gameObject.AddComponent <WarriorTiming>(); warriorTiming.warriorController = this; // Add IKHands. ikHands = GetComponentInChildren <IKHands>(); if (ikHands != null) { if (warrior == Warrior.TwoHanded || warrior == Warrior.Hammer || warrior == Warrior.Crossbow || warrior == Warrior.Spearman) { ikHands.canBeUsed = true; ikHands.BlendIK(true, 0, 0.25f); } } // Setup Animator, add AnimationEvents script. animator = GetComponentInChildren <Animator>(); if (animator == null) { Debug.LogError("ERROR: There is no Animator component for character."); Debug.Break(); } else { animator.gameObject.AddComponent <WarriorCharacterAnimatorEvents>(); animator.GetComponent <WarriorCharacterAnimatorEvents>().warriorController = this; animator.gameObject.AddComponent <AnimatorParentMove>(); animator.GetComponent <AnimatorParentMove>().animator = animator; animator.GetComponent <AnimatorParentMove>().warriorController = this; animator.updateMode = AnimatorUpdateMode.AnimatePhysics; animator.cullingMode = AnimatorCullingMode.CullUpdateTransforms; } // Determine input source. warriorInputController = GetComponent <WarriorInputController>(); if (warriorInputController != null) { useInputSystem = false; } else { warriorInputSystemController = GetComponent <WarriorInputSystemController>(); if (warriorInputSystemController != null) { useInputSystem = true; } else { Debug.LogError("No inputs!"); } } // Setup Rigidbody. rb = GetComponent <Rigidbody>(); if (rb != null) { rb.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ; } currentState = WarriorState.Idle; }