- Home /
Question by
Sillan · Feb 13, 2013 at 08:56 PM ·
instantiateprefabspawn
Instantiate Prefab
Hey Guys, Johnny Here :D I was wondering if anyone knew of a way to instantiate a prefab in this way: I want to instantiate a prefab every so often in the position as a game object in the scene. This is what I have so far:
var spawnpoint:GameObject; // this Gameobject position will be the spawn position
var enemy:GameObject; // I'll put the enemy here to be instantiated
var timeamount :float; // how many seconds to count before an enemy is spawned
InvokeRepeating("Start", 0, (timeamount));
function Start(){
var spawnenemy = Instantiate(enemy, spawnpoint, GameObject.Find("Player").transform.rotation);
}
Could someone please help me? Thanks so much :D
Comment
What problem are you experiencing? One change you need to make for sure is to use a different name for the method you're invoking. Start
is reserved for code that executes when the object is first created. I would suggest rena$$anonymous$$g it to SpawnEnemy
or something meaningful.