//EnemyPersonalities private void ScardyClause() { //Hides/Shoots and hides if (fov.CanSee(target.gameObject) && hearing.CanHear(target.gameObject)) { enemyMode = EnemyMode.Flee; } else if (!hearing.CanHear(target.gameObject)) { enemyMode = EnemyMode.Patrol; } EnemyModeStateMachine(); }
// Update is called once per frame void Update() { if (pawn.target != null) { pawn.Move(1); pawn.RotateToward(pawn.target.position - transform.position); } switch (currentState) { case state.attack: Attack(); //if (sight.CanSee()) //{ // changeState(state.search); //} break; case state.chase: Chase(); //if (IsInAttackRange()) //{ // changeState(state.attack); //} break; case state.patrol: Patrol(); if (hearing.CanHear()) { changeState(state.search); } break; case state.search: Search(); if (Vector3.Distance(transform.position, pawn.target.position) < closeEnough && !sight.CanSee()) { changeState(state.patrol); } break; } }