Answer the question
In order to leave comments, you need to log in
How do I put a few more prefabs in here?
in short, it is necessary that random prefabs spawn, it will not work to throw a few scripts, then they will spawn very stupidly. help make it so that there would be 9 prefabs here and spawn random 1 or 2 at a time.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RandomSpawn : MonoBehaviour
{
[SerializeField] private GameObject prefab;
[SerializeField] private Vector2 spawnRate;
private IEnumerator Start()
{
while (true)
{
yield return new WaitForSeconds(Random.Range(spawnRate.x, spawnRate.y));
var pos = new Vector2(Random.Range(-20, 20), Random.Range(13, 13));
Instantiate(prefab, pos, Quaternion.identity);
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question