As roberbu pointed out you're creating copy of the object you have that script on. But then that object creates a copy of itself and so on and so on.
First question is: what are you trying to do? I.e. what's your goal. There may be a better way.
As for fixing your script, I tested the following as working (creates one copy of object at the location of "target"):
using UnityEngine;
using System.Collections;
public class Spawning : MonoBehaviour {
public GameObject target;
Vector3 spawnSpot;
static bool makeCopy = true;
void Start()
{
if(makeCopy)
{
makeCopy = false;
spawnSpot = target.transform.position;
Instantiate(transform, spawnSpot, Quaternion.identity);
}
}
}
↧