Forgive me, I’ve found a few questions similar to this but all of the fixes have been rather semantic nuances. Im trying to spawn my ‘Enemy’ object, which is just a cube at the moment at 1 of 3 random spawn points in my scene.
using UnityEngine;
using System.Collections;
public class Spawner : MonoBehaviour {
public GameObject Enemy;
GameObject[] objs;
int top;
void Start()
{
objs = GameObject.FindGameObjectsWithTag("Spawn_Point");
top = objs.Length;
InvokeRepeating("CreateObject", 0.01f, 5.0f);
}
void CreateObject()
{
Instantiate(Enemy, objs[Random.Range(0,top)].GetComponent<Transform>().position, Quaternion.identity);
}
void Update () {
Instantiate(Enemy, new Vector3(1, 2, 1), Quaternion.identity);
}
}
Neither the CreateObject() or Update() functions create a new object. Even the basic code given in the instantiate documentation fails.
using UnityEngine;
using System.Collections;
public class TestInstantiate : MonoBehaviour {
public GameObject prefab;
void Start()
{
for (int i = 0; i < 10; i++)
Instantiate(prefab, new Vector3(i * 2.0f, 0, 0), Quaternion.identity);
}
}
Heres a picture of my unity scene with the settings on my Enemy prefab.
[1]: http://i.imgur.com/BoW8q4v.png