// Spawns a random animal from the top of the screen void SpawnRandomAnimal() { float screenTop = vpManager.WTopBorderZ; float randomXPos = Random.Range(vpManager.WLeftBorderX, vpManager.WRightBorderX); animalIndex = Random.Range(0, animalPrefabs.Length); screenOffset = animalPrefabs[animalIndex].transform.localScale.z; Vector3 spawnPos = new Vector3(randomXPos, 0f, screenTop + screenOffset); GameObject spawnedAnimal = Instantiate(animalPrefabs[animalIndex], spawnPos, animalPrefabs[animalIndex].transform.rotation); scoreManager.AddAnimal(spawnedAnimal.GetComponent <Animal>()); }
// Start is called before the first frame update void Start() { animal = gameObject.GetComponent <Animal>(); scoreManager.AddAnimal(animal); animal.OnFullFeed += () => spawnManager.gameObject.SetActive(true); }