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
52
S
26
G
111
Posts: 1,623
Reputation: 62,667

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
19
S
2
G
1
Posts: 24
Reputation: 1,475

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: Blendi1223, jatin1726, kiki4construct, Kyatric, Yahoo [Bot] and 29 guests