Confusion on How Event Works ?

0 favourites
  • 11 posts
  • My brain is fried trying to figure out why this simple event doesn't work as I expected.

    So here it goes:

    1. Move your red Player with arrow keys to the right.

    2. When the red Player overlap with the ShadowCaster, they will spawn a Shadow.

    3. When the red Player is not overlap with the ShadowCaster, shadow will be removed from ShadowCaster.

    Event works fine when all of the ShadowCaster is not line up in X coordinate:

    The exact same event fail when ShadowCaster line up on X coordinate:

    it will no longer destroy the shadow.

    Could someone help me out and explain why this happens ?


  • The problem is with the last condition in the destory shadow event.

    "Shadow --> casterID = ShadowCaster.casterID"

    disable it and it works fine.

    I guess the other instance is and this condition fails.

    If you want it to be specific you could store the IID of shadow to an instance variable in the ShadowCaster, and pick Shadow using it.

  • Thanks Danijerry,

    but if i delete the

    "Shadow --> casterID = ShadowCaster.casterID"

    Then it will destroy all of the shadow, like so:

    i thought that condition is in there so that it will only destroy Shadow for ShadowCaster outside of the Player.

    <img src="" border="0">

    When reading the Destroying Shadow event above, i thought these what suppose to happen:

    1. Pick all ShadowCaster that's not overlap with the Player

    2. Filter again with ShadowCaster that only has Shadow

    3. Pick Shadow that have a "casterID" the same as ShadowCaster filtered from step 2. -> Destroy this picked Shadow

    hmmm... something is not right

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • To clarify the last condition does not go through each of the shadow instead always picks the first instance of the shadow sprite which is the one that is outside the layout which has a casterID of 100. To make this work you may have to go through each shadow using a for loop.

    This may be better!

  • Thanks a lot Danijerry,

    now everything start to make sense to me.

    I guess i can't rely on comparing instance variable to do the filtering / picking, i'll use a direct UID picking as your example in the future <img src="smileys/smiley1.gif" border="0" align="middle" />

  • I guess i can't rely on comparing instance variable to do the filtering / picking..

    Sure you can, used Danijerry's example - download

  • Thanks Noga, looks like using "for each" work like it was intended.

    Now... please check this out, this really blows my mind,

    the exact same logic is applied to this Clown Destroying Kid :D

    and it works just fine, without even using "For Each".

    <img src="" border="0">



    How come it works fine in this case ?

    I really need someone to explain how this whole condition thing works <img src="smileys/smiley29.gif" border="0" align="middle">

  • So what is exactly happens in there, how the condition flows internally ?

    Let say, player is overlap with Clown 77 & Clown 12

    Does it flow like this:

    Kid 13 = Clown 77

    Kid 77 = Clown 77 -> Destroy Kid 77

    Kid 56 = Clown 77

    Kid 56 = Clown 77

    Kid 12 = Clown 77

    Kid 77 = Clown 77 -> Destroy Kid 77

    Kid 80 = Clown 77

    Kid 13 = Clown 12

    (Kid 77 Already destroyed)

    Kid 56 = Clown 12

    Kid 56 = Clown 12

    Kid 12 = Clown 12 -> Destroy Kid 12

    (Kid 77 Already destroyed)

    Kid 80 = Clown 12

  • Actually thats kinda weird when the condition runs like my post above,

    because still using the same example:

    <img src="" border="0" />

    Set 1: Kid 13, Kid 77, Kid 56, Kid 56, Kid 12, Kid 77, Kid 80

    Let say player is overlapping with Set 2: Clown 77, Clown 12

    Action usually run like this:

    Kid 13 = Clown 77

    Kid 77 = Clown 12

    Kid 56 = Clown 77

    Kid 56 = Clown 12

    Kid 12 = Clown 77

    Kid 77 = Clown 12

    Kid 80 = Clown 77

    and it will not destroy anything since no match happen,

    but that's not what happens here, because the event successfully destroy the correct Kid.

    Is the way Condition run & Action run is different ?

  • For your first problem you just need to destroy the initial shadow.

    Start of Layout:
    --Shadow| destroy

    The "A is overlapping B" condition filters object A and loops over all the collision pairs with B. An inverted "A is overlapping B" is just a filter for A.

    So in event 2:

    a. All the ShadowCasters not overlapping the player are selected.

    b. Of the selected only the ShadowCasters with "haveShadow" are selected.

    c. Now each Shadow.CasterID is compared with ShadowCaster.CasterID with this pattern

    1st selected Shadow.CasterID is compared with the 1st selected ShadowCaster.CasterID,

    2nd selected with 2nd selected... and so on.

    You second example runs like this pseudo code:

    For each clown overlapping player:
      if clown havekid:
        select kids with
            destroy selected kids
  • Ah i see, that explain everything

    So let me get it right, in case someone also have similar problem in the future:

    • "Is overlapping" condition will run a "for each" loop for every filtered object.
    • Invert of "Is overlapping" only pick the filtered object (without running "for each" on the filtered object)

    Thanks R0J0hound, everything is cleared up for me now <img src="smileys/smiley1.gif" border="0" align="middle" />

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