void OnEnable(){ _animator = GetComponent<Animator> (); mySences = this.GetComponent<EnemySences>(); source = GetComponent<AudioSource>(); agent = (NavMeshAgent)this.GetComponent("NavMeshAgent"); Player = (GameObject)GameObject.FindGameObjectWithTag("Player"); playerScript = Player.GetComponent<LocomotionPlayer>(); rigidBodies = GetComponentsInChildren<Rigidbody>();//our character is a ragdoll, lets collect its rigidbodies state = Enemy.State.Patrol;//starting state set to idle StartCoroutine("FSMach");//start our state machine }
private Vector3 distanceToTarget; //distance to target void Start() { ///////CACHING VARIABLES _animator = GetComponent <Animator> (); mySences = GetComponent <EnemySences>(); source = GetComponent <AudioSource>(); agent = (UnityEngine.AI.NavMeshAgent) this.GetComponent("NavMeshAgent"); Player = (GameObject)GameObject.FindGameObjectWithTag("Player"); playerScript = Player.GetComponent <CharacterControl>(); rigidBodies = GetComponentsInChildren <Rigidbody>(); //our character is a ragdoll, lets collect its rigidbodies state = Enemy.State.Idle; //starting state set to idle StartCoroutine("FSMach"); //start our state machine //foreach (Rigidbody rb in rigidBodies){//lets make all reigidbodies of the character kinematic // rb.isKinematic = true; //} //foreach (Collider col in ragDallColliders){ // col.enabled = false;//lets make all the colliders of the character disabled //} }
private Vector3 lookDirection;//look direction void Start () { ///////CACHING VARIABLES _animator = GetComponent<Animator> (); mySences = this.GetComponent<EnemySences>(); source = GetComponent<AudioSource>(); agent = (NavMeshAgent)this.GetComponent("NavMeshAgent"); Player = (GameObject)GameObject.FindGameObjectWithTag("Player"); playerScript = Player.GetComponent<LocomotionPlayer>(); rigidBodies = GetComponentsInChildren<Rigidbody>();//our character is a ragdoll, lets collect its rigidbodies state = Enemy.State.Patrol;//starting state set to idle StartCoroutine("FSMach");//start our state machine m_AudioSource = GetComponent<AudioSource>(); //foreach (Rigidbody rb in rigidBodies){//lets make all reigidbodies of the character kinematic // rb.isKinematic = true; //} //foreach (Collider col in ragDallColliders){ // col.enabled = false;//lets make all the colliders of the character disabled //} }