Beginners Tute - Questions

Just started using Construct 2? Post your questions here

Post » Wed Apr 16, 2014 5:18 am

Hi,

On pg.7 of the Jungle Beginners tute it says:

Now to flip the snail's direction on the edges:

Event: SnailEnemy -> On collision with another object -> EdgeMarker
Subevent: SnailEnemy -> Compare instance variable -> action equal to "right"
Action: SnailEnemy -> Set value -> action to "left"
Subevent: Else
Action: SnailEnemy -> Set value -> action to "right"

It's important to use Else here, because events are run from top-to-bottom. If instead of 'else' we said 'action equal to "left"', notice the previous event would have just set it to that. So it'd just set it right back again, having no overall effect. By using 'else', we prevent the second event running if the first was true.


If instead of 'else' we said 'action equal to "left"' wouldn't the snail still move left because it is no longer "on collision with EdgeMarker"? Or if it is, then shouldn't the snail keep turning left, then turning right indefinately? What actually happens is the snail continues as if the collision with EdgeMarker does not mean anything. Why is that?
B
3
Posts: 5
Reputation: 185

Post » Wed Apr 16, 2014 9:45 am

because of what the quote says.... the system doesn't check the initial condition for each sub event. it only checks the condition once, and then runs all sub events in order. and as the quote explains. if you use the "compare" instead of "else" it will, in one tick, turn in to one side and then back to the other (1 tick is quite so fast you won't notice any change). and collision only triggers on first contact. which means that if the object already collide, it won't check as if true again unless they disengage and then collide again.

also, on collision is a trigger, not a condition =P

so, do as the example says. use Else.
B
43
S
12
G
6
Posts: 446
Reputation: 6,802

Post » Wed Apr 16, 2014 12:26 pm

Oh right, got it thanks! Loved the passive aggression in your answer as well, totally uncalled for, but hilarious! Keep it up.

By the way, the quote does not say "it only checks the condition once, and then runs all sub events in order" it says that "events are run from top-to-bottom". It does not say that if a condition is satisfied, the next sub event runs anyway, which is what you have clarified for me.
B
3
Posts: 5
Reputation: 185

Post » Wed Apr 16, 2014 1:02 pm

@Roger3471 haha, sorry about the passive aggressiveness, it was not intended =O. My first language is not english. maybe I miscalculated the tone? anyway, I helped :D
B
43
S
12
G
6
Posts: 446
Reputation: 6,802

Post » Wed Apr 16, 2014 1:13 pm

:D Certainly did, thanks.
B
3
Posts: 5
Reputation: 185


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests