我的场景中有 3 个空的游戏对象,我试图在其上生成对象,我编写了此脚本,以便在生成器之间有一个 RNG 值,以便生成对象。
我遇到了问题,但不太确定如何解决
public class Spawns : MonoBehaviour
{
public GameObject SpawnedObject;
public bool StopSpawn = false;
public float SpawnTime;
public float SpawnDelay;
public GameObject[] SpawnPoints;
int Randomint;
// Start is called before the first frame update
void Start()
{
InvokeRepeating("SpawnObjects", SpawnTime, SpawnDelay);
}
public void SpawnObjects()
{
Randomint = Random.Range(0, SpawnPoints.Length);
Instantiate(SpawnedObject[Randomint], transform.position, transform.rotation);
if (StopSpawn)
{
CancelInvoke("SpawnObjects");
}
}
}
繁花不似锦
相关分类