Picking question

Get help using Construct 2

Post » Sat Mar 09, 2013 6:30 am

I'm trying to pick a random object, from 50 objects, which has a certain variable set, but must NOT have another set.

So I'm doing....

Object Var1 = 1
Object Var2 <> 2
Pick a random Object.

It's not working. It IS getting all the objects with var1 set to 1, but it's also occasionally grabbing objects where var2 = 2, which it shouldn't be doing?
B
25
S
5
G
3
Posts: 446
Reputation: 5,633

Post » Sat Mar 09, 2013 7:05 am

Your logic seems correct to me. Post a capx?
Mistakes were made.
B
37
S
17
G
67
Posts: 1,041
Reputation: 38,211

Post » Sat Mar 09, 2013 10:51 am

Your logic seems fine. I've tried this:

Every time you click a sprite the system adds one to the second variable.
Then it picks every second a random instance within the given constraints.
A touch outside resets the second variable of all instances.



Have funmoonworX2013-03-09 11:40:46
B
18
S
2
G
1
Posts: 23
Reputation: 1,448

Post » Sat Mar 09, 2013 2:54 pm

Thanks. I was wondering if there was something wrong with the logic of checking if a variable is NOT a certain number during the picking process, but if your example works, then I can't fathom why mine doesn't. It's still picking the variable which is not selected, maybe I have to indent the 'pick' command or something.

* Worked this one, it was an error in my code thankfully, the variables were being reset elsewhere. Doh.farflamex2013-03-09 15:00:08
B
25
S
5
G
3
Posts: 446
Reputation: 5,633


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 9 guests