How do I randomly generate specific numbers?

Get help using Construct 2

Post » Fri Nov 28, 2014 5:47 pm

I have a waypoint system set up I would like to do, to move enemies around, without the pathfinding behavior.

When they collide with specific waypoints, it will change their direction based on a number value.

The problem is, I don't want it to always choose all 4 random numbers. Sometimes, I would want it to pick a random number out of 2 numbers, or 3 numbers, so how would I do that?

I know how to randomly generate the 4 numbers, but what would I do if I wanted it to set it to either 0, or 2? Or 1 and 4, or 0,1 and 4?

thanks!
B
4
Posts: 78
Reputation: 606

Post » Fri Nov 28, 2014 6:08 pm

Try choose(n0,n1,n2), or just use int(random(4)) would get 0-3 which you can reference 0 do this, 1 do foo, etc.
Image ImageImage
B
168
S
50
G
164
Posts: 8,228
Reputation: 105,575

Post » Fri Nov 28, 2014 6:21 pm

two different options (event 1 or events 2 and 3)
Image
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Fri Nov 28, 2014 6:23 pm

Hexxiss wrote:. The problem is, I don't want it to always choose all 4 random numbers. Sometimes, I would want it to pick a random number out of 2 numbers, or 3 numbers, so how would I do that?

I know how to randomly generate the 4 numbers, but what would I do if I wanted it to set it to either 0, or 2? Or 1 and 4, or 0,1 and 4?

thanks!


use instance variables for enemy..
var=1 ..choose(1,4)
var=2 ..choose(0,3)
...........
Image
B
64
S
23
G
7
Posts: 1,482
Reputation: 10,825


Return to How do I....?

Who is online

Users browsing this forum: justifun and 10 guests