Instantiate loops until unity crashes...

Hey I’m trying to instantiate an object but all it seems to do is keep making clones until unity crashes. I only need 3 clones. What am I doing wrong?

void Start () 
{
	rotation.x = Random.Range(-0.1600f, -0.2200f);
	int startrot = Random.Range(0, 360);
	
	transform.rotation =  Quaternion.Euler(startrot, 0, 0);
	// Array 0=0 1=1 ... 9=9
	for(int i = 0; i < 10; i++)
	{
		myDegrees_=270-(36*i);_

_ Debug.Log(“InputArray” + myDegrees*);_
_
}*_

* for(int c = 0; c < 3; c++)*
* {*
* Instantiate(prefab, new Vector3 (37, 0, 0), Quaternion.identity);//as Transform;*
* Debug.Log ("c= " + c);*
* }*

* }*

Weird. I tried the spawning code from above, and don’t seem to be having that problem.

using UnityEngine;
using System.Collections;

public class Spawner : MonoBehaviour {

    public GameObject prefab;
    void Start()
    {
        for (int c = 0; c < 3; c++)
        {
            Instantiate(prefab, new Vector3(37, 0, 0), Quaternion.identity);//as Transform;
            Debug.Log("c= " + c);
        }
    }
}

It spawns all three prefabs for me. Are you getting any warnings?

Hey SirVictory,

Thanks for your reply, I did the same thing as you just made a new prefab and restarded, and its fixed now. Just redid the prefab. The problem was that it just kept making clones in an endless loop for no reason. Bug? :).

Cheers man!

Maybe your script was attached to the initial prefab? Every copy got the script attached to them again, so they keep copying themselves…