Answer the question
In order to leave comments, you need to log in
A huge number of objects spawn, what should I do?
The code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Spawn : MonoBehaviour
{
public GameObject Smile;
private void Start()
{
StartCoroutine(SummonSmile());
}
IEnumerator SummonSmile()
{
while (true)
{
SpawnSmile();
yield return new WaitForSeconds(1);
}
}
private void SpawnSmile()
{
Instantiate(Smile, new Vector2(Random.Range(-2, 2), 6f), Quaternion.identity);
}
}
Answer the question
In order to leave comments, you need to log in
while (true)
{
SpawnSmile();
yield return new WaitForSeconds(1);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question