public virtual void Start() { enemy = GetComponent<Enemy>(); patrol = new PatrolState(this); // create the state attack = new AttackState(this); die = new DieState(this); //set the patrol points foreach (string name in PatrolPointNames) { GameObject point = GameObject.Find(name); if (point != null) { Transform t = point.GetComponent<Transform>(); patrol.PatrolPoints.Add(t); } } States.Add(patrol); // add to the list States.Add(attack); States.Add(die); ChangeState(patrol.GetKey()); // set the first state to patrol }
void Start() { controller = GetComponentInParent<EnemyController>(); trans = GetComponent<Transform>().parent.GetComponent<Transform>(); enemy = GetComponentInParent<Enemy>(); }