Emitting objects at a progressive rate randomly in a 2D game

I am planning on developing a small 2D Android and iPhone game and I need to go over a few things before I can start building.

I was wondering how to build a script in Javascript to emit a prefab within a ring-like parameter in a 2D style game. I will try to explain with images.

11193-untitled.png

In this image, The green square represents the Camera’s view, and the red ring of sorts represents the parameters of which I want the enemies (those blob things) to spawn.

I need help developing a script that randomly generates a position within the parameter and places an object of choice there (to be changed in the inspector tab). I also need to have the spawn rate changeable through time, as in it spawns faster over a period of time.

If anyone can help me, it would be so great. I’m willing to go into further detail, so just ask if you need that.

Thanks.

How about using 2 random numbers one for magnitude, which would be between the 2 radii and one for direction (angle) which would be between 0 and 2pi. Then you can use sin/cos to get the x and y values. Then cast that to a vector and pass it into the Instantiate function you are already calling :slight_smile: