How do I generate random variables on separate objects?

Get help using Construct 2

Post » Sun Oct 02, 2016 3:07 pm

I have this
Image

but it doesn't set it to anything but variable "0" for "Type".

If I force a number like 1 or 2. It loads properly in...
B
7
Posts: 28
Reputation: 333

Post » Sun Oct 02, 2016 3:17 pm

I would take the for each EnemyCntrl out of the nested loop and have a separate event, on EnemyCntrl created > set type to random (0,2) but that's just me.
Last edited by plinkie on Sun Oct 02, 2016 3:18 pm, edited 1 time in total.
B
46
S
16
G
73
Posts: 2,080
Reputation: 43,669

Post » Sun Oct 02, 2016 3:17 pm

System expressions

random(x)
Generate a random float from 0 to x, not including x. E.g. random(4) can generate 0, 2.5, 3.29293, but not 4. Use floor(random(4)) to generate just the whole numbers 0, 1, 2, 3.
Image
B
65
S
23
G
7
Posts: 1,501
Reputation: 10,888

Post » Sun Oct 02, 2016 4:45 pm

For any floating point number: random(2)
If you only want integers floor( random(2) )
B
28
S
10
G
10
Posts: 97
Reputation: 6,584

Post » Sun Oct 02, 2016 5:28 pm

Well I did this...
Image

still doesn't seem to work... it doesn't seem to affect the new spawning ones
B
7
Posts: 28
Reputation: 333

Post » Sun Oct 02, 2016 5:36 pm

Image
korbaach wrote:System expressions

random(x)
...Use floor(random(3)) to generate just the whole numbers 0, 1, 2,
Image
B
65
S
23
G
7
Posts: 1,501
Reputation: 10,888

Post » Sun Oct 02, 2016 5:44 pm

korbaach wrote:Image
korbaach wrote:System expressions

random(x)
...Use floor(random(3)) to generate just the whole numbers 0, 1, 2,


Oh "floor" isn't just a random object word? I thought it was an example... uh I'm dumb...

I appreciate everyone putting up with me here.


EDIT:

Seems to be affecting only one area now...

Image
B
7
Posts: 28
Reputation: 333


Return to How do I....?

Who is online

Users browsing this forum: rayolf and 11 guests