// Reset Function public override void ResetEnemy(SpawnZone newSpawnZone, Vector3 newPos) { // play sound SoundManager.instance.PlaySound("BirdWings"); // Reset Shared Data base.ResetEnemy(newSpawnZone, newPos); // Get your new waypoint here.. SetWaypointGroup(newSpawnZone.GetComponent <SpawnZone>().GetRandomPath()); }
private void SpawnEnemy(EnemyData enemy, int count) { var spawnRenderer = _spawnzone.GetComponent <Renderer>(); var bounds = spawnRenderer.bounds; var randomPoint = bounds.center + new Vector3( (Random.value - 0.5f) * bounds.size.x, (Random.value - 0.5f) * bounds.size.y, (Random.value - 0.5f) * bounds.size.z ); for (int i = 0; i < count; i++) { NavMeshHit hit; if (!NavMesh.SamplePosition(randomPoint, out hit, 3f, NavMesh.GetAreaFromName(SPAWN_NAV_MESH_LAYER))) { Debug.LogError("Failed to get random position on spawn nav mesh layer"); return; } var prefab = enemy.Prefab; _instantiator.InstantiatePrefab(prefab, hit.position, Quaternion.identity, null); } }