How do I properly make subevent conditions work?

Get help using Construct 2

Post » Sun Feb 15, 2015 2:14 pm

When activating a function, I have an event that is only supposed to occur if a variable is not equal to 0. The event always happens, regardless of variable state. Please help? :)
B
18
S
3
G
3
Posts: 82
Reputation: 2,543

Post » Sun Feb 15, 2015 2:18 pm

Are you 100% sure this number will eventually reach 0 ? If you are checking a speed, opacity or something like that, it may avoid this value so you have to be less precise.
For example if round(variable) = 0, or if variable < 1, stuff like that.
B
12
S
7
G
7
Posts: 448
Reputation: 4,272

Post » Sun Feb 15, 2015 2:29 pm

Pretty sure, yeah. Attached is a .capx demoing my problem.
You do not have the required permissions to view the files attached to this post.
B
18
S
3
G
3
Posts: 82
Reputation: 2,543

Post » Sun Feb 15, 2015 2:31 pm

Essentially I set up the capx like this:

On Space Bar Released & Variable = 0:
Make sprite more thin.
Variable = 1

On Space Bar Released & Variable =1:
Make sprite less thin.
Variable = 0.

If you disable either, the other works. If you leave them both, they both occur, despite logic gating the variable.
B
18
S
3
G
3
Posts: 82
Reputation: 2,543

Post » Sun Feb 15, 2015 2:42 pm

WHOOPS. Okay I figured it out. By adding a "Wait 0.1 seconds" event in, it did not trigger the next event on the same tic. Okay, thanks guys! Y'all are awesome.
B
18
S
3
G
3
Posts: 82
Reputation: 2,543

Post » Mon Feb 16, 2015 10:45 am

If you have to use a wait action to make it work, then your events are not set the way they should.

Construct read events once/tick and from top to bottom.
Basically, it executes your two conditions "on space released" at the same tick and this is why it doesn't work. Your two "on space released" conditions are both verified and executed.

So I suggest you to consider making something like this :
events.png
You do not have the required permissions to view the files attached to this post.
B
12
S
7
G
7
Posts: 448
Reputation: 4,272

Post » Tue Mar 03, 2015 8:48 am

Huh. Thanks! That's a much more efficient way of performing that. Thank you!
B
18
S
3
G
3
Posts: 82
Reputation: 2,543


Return to How do I....?

Who is online

Users browsing this forum: alajajm, LaurenceBedford, tetuan and 11 guests