Instantiate (480676)

Hi all,
I have tried to find the way to do this, and feel like i’m running around in circles.
All I want to do is run the Instantiate, have it repeat it’s action every (between 5-10 secs).

However I seem stuck lol.
I can’t get it to repeat every 5secs continually.

Code:

var thePrefab : GameObject;

function Start () {

InvokeRepeating(“”,0,5);

var instance : GameObject = Instantiate(thePrefab, transform.position, transform.rotation);

}

I’ve tried thePrefab to get it to start repeating. nothing.

I have a destroy script on the Obj clone that gets created on Instantiate, but that only destroys the cloned Obj when it hits the floor.

Any help would be greatly appreciated.

You need to supply a function to use with InvokeRepeating, and then put your code in that function. See the docs.

–Eric

@Eric5h5: Cheers, much appreciated.

okay so I got it repeating, the only problem I have with it is the location of where it is repeating from. It will spawn 1 ‘shot’ from the instantiate game obj,
then it will repeat shooting from 0,0,0 for some reason. So if i try to have multiples, I’ll get a couple of ‘shots’ but then it’ll multishot from 0,0,0 throwing my objects everywhere lol.

Any idea on how to resolve that?

It instantiates objects wherever you tell it to, so I guess you’re telling it to instantiate at 0,0,0 somehow.

–Eric