public override void Update(EnemyAgent agent) { //check if target still in attack range if yes attack again after ending the attack animation agent.SetPlayerTarget(); if (Vector3.Distance(agent.GetNavMeshAgent().destination, agent.transform.position) < agent.GetAttackRange()) { if (agent.GetCurrentTimeBtwAttacks() <= 0) { agent.Attack(); } else { agent.AdjustAttackTime(); } } else { agent.SetState(FollowPlayerState.GetInstance()); } }
public override void Update(EnemyAgent agent) { //update position of the player agent.SetPlayerTarget(); if (Vector3.Distance(agent.GetNavMeshAgent().destination, agent.transform.position) < agent.GetAttackRange() + 0.5f) { agent.SetState(AttackState.GetInstance()); } if (Vector3.Distance(agent.GetNavMeshAgent().destination, agent.transform.position) > agent.GetFollowRange() + 0.5f) { if (agent.GetIsWaveEnemy() == false) { agent.SetState(PatrolState.GetInstance()); } else { agent.SetState(ChargeBaseState.GetInstance()); } } }
public override void Enter(EnemyAgent agent) { agent.GetNavMeshAgent().isStopped = false; agent.SetPlayerTarget(); }