public class Spwan : MonoBehaviour
{
public GameObject AnimalPrefebs;
public float SpawnSitX= 20;
public float SpawnSitZ = 30;
public float startDelay = 2F;
public float spawnInterval = 1F;
// Start is called before the first frame update
void Start()
{
{
InvokeRepeating("SpawnRandomAnimal",startDelay,spawnInterval);
}
void SpawnRandomAnimal()
{
int AnimalIndex = Random.Range(0, AnimalPrefebs.Length);
Vector3 SpwanPos = new Vector3(Random.Range(-SpawnSitX, SpawnSitX), 0, SpawnSitZ);
Instantiate(AnimalPrefebs[AnimalIndex], SpwanPos, AnimalPrefebs[AnimalIndex].transform.rotation);
}
}
// Update is called once per frame
void Update()
{
}
The indentation will show you the hierarchy of your methods, you can spot added or missing { } based on that. Be sure to format the document often, I have auto-format on save enabled.