// Update is called once per frame void Update() { if (Time.time - timeSinceGameStart > bunnyCreationFrequency) { timeSinceGameStart = Time.time; Instantiate(bunnyPrefab, world.LocalToWorldCoordinates(new Vector3(Random.Range(min_x, max_x), world.ySize + 5, Random.Range(min_z, max_z))), Quaternion.Euler(0, Random.Range(0, 360), 0), bunnyCollection.transform); } }
// Update is called once per frame void Update() { if (Time.time - lastFoodGenerationTime > foodGenerationFrequency) { lastFoodGenerationTime = Time.time; float x = Random.Range(0, world.xSize - 1); float z = Random.Range(0, world.zSize - 1); float y = 0.5f; while (world.IsSet((int)x, (int)y + 1, (int)z)) { y += 1.0f; } y += 1.0f; Vector3 carrotPos = world.LocalToWorldCoordinates(new Vector3((int)x, (int)y, (int)z)); Instantiate(foodPrefab, carrotPos, Quaternion.identity, foodCollection.transform); //GameObject.CreatePrimitive(PrimitiveType.Sphere).transform.position = carrotPos; } }