public void Attack(Vector3 target) { var rp = target - Position; Rotation = Quaternion.LookRotation(rp); _weaponModel.Rotation = Rotation; _weaponModel.Fire(); _navMeshAgent.SetDestination(target); _navMeshAgent.stoppingDistance = 6; }
public void Do() { if (_state == BotState.Death) { return; } var point = Helper.GenericPoint(transform); switch (_state) { case BotState.Empty: case BotState.Patrol: if (!_navMeshAgent.hasPath) { _navMeshAgent.SetDestination(point); _navMeshAgent.stoppingDistance = 1; } else { if (Vector3.Distance(point, transform.position) <= 1) { _state = BotState.Observation; Invoke(nameof(ReadyPatrol), _cooldown); } } break; case BotState.Observation: // TODO: Сделать поворот головы break; case BotState.Aggression: _navMeshAgent.SetDestination(_activeTarget.Position); _navMeshAgent.stoppingDistance = 6; _weaponModel.Fire(); break; case BotState.Repeat: _navMeshAgent.SetDestination(point); _navMeshAgent.stoppingDistance = 1; _state = BotState.Patrol; break; case BotState.Death: CancelInvoke(); return; } if (_targets.Any(target => Helper.SeeTarget(transform, target.transform))) { _activeTarget = _targets.First(target => Helper.SeeTarget(transform, target.transform)); _state = BotState.Aggression; CancelInvoke(); } else if (_state == BotState.Aggression) { _state = BotState.Repeat; } }