private void Update() { //waits until stateSeconds has passed before switching states //if (Time.time > gameTimer + 1) //{ // gameTimer = Time.time; // seconds++; // //Debug.Log(seconds); //} //if (seconds == stateSeconds) //{ // seconds = 0; // chasePlayer = !chasePlayer; //} if (currentState != "chase" && fov.IsInView()) { currentState = "chase"; ai.maxSpeed = chaseSpeed; stateMachine.ChangeState(EnemyChaseState.Instance); } else if (currentState != "patrol" && !fov.IsInView()) { currentState = "patrol"; ai.maxSpeed = patrolSpeed; stateMachine.ChangeState(EnemyPatrolState.Instance); } ai.destination = target.position; stateMachine.Update(); }
// Update is called once per frame void Update() { //Debug.Log("Timer:"+(Time.unscaledTime - startStateTime)); //Debug.Log(stateChangeInterval); //Debug.Log(Time.unscaledTime - startStateTime > stateChangeInterval); if (Time.unscaledTime - startStateTime > stateChangeInterval) { startStateTime = Time.unscaledTime; searching = !searching; GoToNextState(); } if (fov.IsInView() && currentState != MonsterState.KillMode) { ChangeState(MonsterState.KillMode); } ai.destination = target.position; stateMachine.Update(); }