How do I : Pick 2 or more instances with the same value

Get help using Construct 2

Post » Sun Jan 10, 2016 7:45 pm

Hey guys, I'm trying to assign random integer values to various instances. I want each instance to have its own unique value.

But when i randomly assign one there is a chance, a small one, that 2 or more instances might have the same value.

What should I do to prevent this?

Thanks for your help and time!
B
5
Posts: 23
Reputation: 271

Post » Sun Jan 10, 2016 8:06 pm

One solution is to put all numbers assigned in a array and each time you random a new number, you verify if it exists in the array yet, if not, put it in the array.
B
18
S
4
G
1
Posts: 143
Reputation: 1,868

Post » Sun Jan 10, 2016 9:40 pm

Thanks! Tried what you suggested, and got it to work! Many many thanks!
B
5
Posts: 23
Reputation: 271


Return to How do I....?

Who is online

Users browsing this forum: corpvs2, dop2000, farsen and 27 guests