// Start is called before the first frame update void Start() { currentState = patrolState; SetCloseTarget(); currentState.StartState(); }
public void OnTriggerEnter(Collider other) { // Interrupt for death sequence if (other.CompareTag("Player")) { currentState = deathState; } //currentState.OnTriggerEnter(other); }
// Update is called once per frame void Update() { // Update current state currentState.UpdateState(); // Detect state change and call StartState method in current state if (previousState != null && previousState != currentState) { Debug.Log("State changed! " + previousState + " -> " + currentState); // Activate start state currentState.StartState(); } // Update previous state previousState = currentState; }