- Home /
Question by
Fallen117 · Jul 14, 2015 at 02:40 PM ·
instantiateprefab
Prefabs dont instantiate directly on point
So I am trying to get all these prefabs to spawn on a certain point. Some spawn perfectly, while others spawn off point on the Z axis
public GameObject[] prefab;
public Transform spawnrotation;
public float speed;
public int raysize;
private Rigidbody rb;
void Start ()
{
StartCoroutine(StartLoader());
}
IEnumerator StartLoader ()
{
//void Update()
{
transform.rotation = Quaternion.identity;
int prefab_num = Random.Range (0, raysize);
Instantiate (prefab [prefab_num], spawnrotation.position, spawnrotation.rotation);
yield return new WaitForSeconds(speed);
}
{
StartCoroutine(StartLoader());
}
}
}
Comment