Beginners Tute - Questions

0 favourites
  • 5 posts
From the Asset Store
The perfect way to start development of multiplayer games
  • Hi,

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

    [quote:ztt5h4bf]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?

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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

  • Certainly did, thanks.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)