x


Various of Random Numbers?

i'm so sorry, for double posting, but my last post is a mess, and i can't get my head around it.

what i'm trying to do, is create random X position, for my spawn point, where it would instatiate a x number of enemies. i'm tryng to use Random.Range, but all it does it create one random number. all my enemies get's instantiated at that one spot each game load. how can i generate a bunch of random of random numbers so, my spawnpoint, spawns at different, positions?

i suppose i could set 3 variable, which are equal to a Random,Range, i'll try that now.

more ▼

asked Sep 12 '10 at 07:19 AM

Nathan Bennett gravatar image

Nathan Bennett
154 31 33 35

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

you should generate a random number each time you instantiate an enemy. like this:

for (i=0;i<5;i++){
  var rnd = Random.Range(0,10);
  Instantiate(enemy,Vector3(rnd,5,5),Quaternion.identity);
}
more ▼

answered Sep 12 '10 at 11:22 AM

AliAzin gravatar image

AliAzin
2.5k 42 56 79

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x573
x106
x19

asked: Sep 12 '10 at 07:19 AM

Seen: 1094 times

Last Updated: Sep 12 '10 at 07:19 AM