Some questions about instantiate.

Hello, I have some questions about using instantiate:

1: If I set boundaries, how can I have enemies spawn at random points within the boundaries (like spawning at a random point within this room)? I saw in the documentation you can set a grid and then spawn enemies at a set distance but what about at any point in the grid (my game has a 2D perspective along the ZX plane if that helps).

2: How can I use call instantiate at the end of a set time interval? Would I use Time.DeltaTime?

3: How would I instantiate a set of objects using another set of objects (ex: out of 5 objects instantiate three of them)? Would I have to use Random.value for each object(If 1 = instantiate?)

Thank you.

I’m not sure what you mean by ‘setting boundaries’… how are your boundaries represented? You can pass the position to instantiate at into the Instantiate() function, so all you need to do is make sure the position you pass in is within your boundaries. Unity doesn’t know anything about ‘grids’, so unless you need to define one for your own reasons, you can probably ignore that.

[QUOTE
2: How can I use call instantiate at the end of a set time interval? Would I use Time.DeltaTime?
[/QUOTE]

The easiest way would probably be to start a co-routine that does a ‘yield WaitFor…’ before the Instantiate() call. Again, though, it depends on what exactly you’re trying to do.

[QUOTE
3: How would I instantiate a set of objects using another set of objects (ex: out of 5 objects instantiate three of them)? Would I have to use Random.value for each object(If 1 = instantiate?)
[/QUOTE]
Again, it’s not very clear what you want to do, but if you want random selection then yes, the Random class is what you’re looking for. Random.Range() might be easier to use than Random.value for this though.