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 }
void Start() { PlayerAC = gameObject.GetComponent <LocomotionPlayer>(); // 设置ID SetID(++EntityManager.lastEntityID); for (int i = 0; i < arraryOfVoices.Length; i++) { PlayerVoices.Add(arraryOfVoices[i].name, arraryOfVoices[i]); } voice = this.gameObject.GetComponent <AudioSource>(); EntityManager.Instance().RegisterEntity(this); target = GameObject.FindGameObjectWithTag(Tags.Leader); States = this.gameObject.transform.FindChild("PlayerStates").GetComponent <PlayerStates>(); m_pStateMachine = new StateMachine <Player>(this); m_pStateMachine.SetCurrentState(States.EmptyState); }
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 //} }