I'm trying to make an object that'll duplicate itself in random positions, but when I duplicate it, it also duplicates the code. The clone then starts the code which makes another code, exponentially killing my computer. Is there a way to fix this?
public class CloneMe : MonoBehaviour
{
// Start is called before the first frame update
public GameObject self;
void Start()
{
int amountOfClones = Random.Range(10, 15);
for (int i = 0; i < 1; i++)
{
transform.position = new Vector2(Random.Range(0, 7), Random.Range(0, 7));
Instantiate(self);
}
}
}
There's no errors showing up from Unity, just insane lag that makes me have to unplug my computer.
↧