Random Spawn Picker

A basic script that allows you to place multiple spawn points in which a specified object will randomly chose a point to spawn from. Just ensure the object being spawned has a rigidbody.

var spawn : Transform[];
var objectToSpawn : GameObject;
var start : int = 2;
var interval : int = 5;

InvokeRepeating("Spawn", start, interval);

function Spawn() {

     var randomPick : int = Mathf.Abs(Random.Range(0,3));
     var thingToSpawn = Instantiate(objectToSpawn, spawn[randomPick].position, spawn [randomPick].rotation);


About AK Studio Development

We are a small indie development group from New Zealand. We have been dabbling in iPhone app and game development since 2010 and are continuously learning new tricks. As we learn, we create. We look forward to sharing all our ideas through our current and future apps! AK Studio

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: