[Solved]OR blocks are broken

0 favourites
  • 14 posts
From the Asset Store
Physics Block Puzzle game template for Construct 3
  • Problem Description

    Or blocks are broken.

    Attach a Capx

    Here

    Description of Capx

    2 Sprite objects, Events - If Layer 1 is not visible OR Sprite.var=1 - Rotate Sprite and Sprite2, Layer 1 is not visible and Sprite.var=0 from the start.

    Steps to Reproduce Bug

    • Open capx
    • Start preview
    • Sprite is not rotating, but Sprite2 is rotating, only half actions happened.

    Observed Result

    If in OR block, "Sprite.var=1" or any other condition that picking Sprite is not True, then all Sprite instances will be un-picked in the whole OR event and it's subevents.

    Layer 1 is not visible, means a condition from or block is true, but not all actions in or block happened, only Sprite 2 is rotating, Sprite is not. All actions happen only if all conditions are true, or only Sprite.var=1 is true, or if i put Pick All Sprite event under OR block, but not if Layer 1 is not visible is true.

    Expected Result

    It's not right to un-pick all Sprite instances, and don't apply actions for them, if in OR block "Sprite.var=1" condition (or other picking condition for this object) is not True, but other conditions are True. If a picking condition is not True in OR block, this condition should not do anything, not pick any instances, and not un-pick them. Why is this picking 0 instances if "Sprite.var=1" is not true?

    Since the event says rotate both sprites if any condition is true, and the 1st condition is true i want it to rotate both sprites.

    Affected Browsers

    • Chrome: (YES)
    • FireFox: (YES)
    • Internet Explorer: (YES)

    Operating System and Service Pack

    Windows 7

    Construct 2 Version ID

    r209

  • This seems to work as intended though.

    Your object compare variable works as a picking variant in combination with the OR.

    Seeing how the object does not have the same value as in your event, it just picks the one.

    If you change it to a: System, compare 2 variables, it works how you want it to work.

    Or

    If you change the 1 to 0 in your events (not compare 2 values), it also uses the object with var = 0

    Or

    IF you copy your lightblue sprite, and give it var = 1 it will rotate too.

    I think this stems from a misunderstood expectancy.

  • I think that you could reasonably argue that if the OR block returns True then both of the sprite objects should be rotated - there should be no picking unless the True condition was also an object filter...

    :/

  • I think that you could reasonably argue that if the OR block returns True then both of the sprite objects should be rotated - there should be no picking unless the True condition was also an object filter...

    :/

    Its combined in this situation, normally, if you use the event by itself, object.var =1, then the object would not get selected and not rotate either.

    The correct method of use would be to use the system compare two values, to avoid the object selection.

    The expectancy here is that the object.var = 1 should work as a compare function ... which it is not.

    There is a clear, compare two values, option for that.

  • lennaert Yeah, i see that this is a problem with picking, not with or blocks itself, but the problem is

    [quote:10o1nrs4]Your object compare variable works as a picking variant in combination with the OR.

    Seeing how the object does not have the same value as in your event, it just picks the one.

    It doesn't pick anything at all, and replacing the "compare with object picking" with "system - compare two values" is not always a workaround, think if i need to fire an event if 1 object overlaps 2 OR 3 object overlaps 4, "Is overlapping" is the picking condition.

    Edit: Try to add event like simple Layer 1 is visible - Rotate Sprite, It will pick all Sprite instances, if we use OR block with picking condition it will not pick anything unless there's a pick-condition that is true.

  • lennaert, I agree with your analysis, I just think it's not an intuitive OR function. I just re-read the manual page on this to be sure of my facts (it's been a while), and all it says is the condition filters instances for subsequent events - and the OR block is certainly a condition. It's just that, in this case, it's just filtering in a way I personally wouldn't expect. It's one for the user to be wary of (and I'm not convinced it's a bug)....

  • Sisyphus - the manual page specifically describes system conditions (like layer visibility) as not filtering for subsequent events; whereas a condition with an object will, by definition, filter subsequent objects - it's just not clear there that ALL condition lines in the OR block will filter, even if some of them are not True.

  • Colludium At least if it's a feature, the feature like not picking all objects inside OR block without true picking condition, must be stated in manual with workaround.

  • Its a picking variant, not really picking.

    I did not mean to replace it with an actual picking event, such as pick by comparison.

    I suggested to replace your object compare with a (system), Compare 2 values.

    Its more of a filter perhaps then a picking variant, but the result is the same.

    Its like, when you use an objects compare function, you end up with the objects having the same value.

    ie

    100 objects, 10 have var = 1

    Event:

    Objects.var = 1

    For each

    Placing it in this order, would only make the for each loop through all the objects with a var = 1, and not use the objects var <> 1

    (Loop = 10 objects big)

    unlike

    Event

    for each object

    object.var = 1

    Where it loops through all objects and only uses the object where var = 1

    (loop = 100 objects big)

  • lennaert I got your point, but as i said above, in my game i have an event like - If "Wheel" Overlaps "Ground" OR "Second Wheel" Overlaps "Ground" - do something with both wheels, but if one wheel is overlapping ground, something will be done only with that one wheel, because the second wheel will not be picked. That's a little not a thing that i expect by this OR block.

  • Ah, I see.

    In those situations I just add a subbed picking events with references to local variables or booleans

    pick all wheels,

    pick by evaluate wheels spinning = true

    It seems that the OR block's wide, unrestricted options, leaves the manual with some grey areas

  • Ah, I see.

    In those situations I just add a subbed picking events with references to local variables or booleans

    pick all wheels,

    pick by evaluate wheels spinning = true

    It seems that the OR block's wide, unrestricted options, leaves the manual with some grey areas

    Yes, in the original post i stated that if i repick all objects with Pick All in a sub-event of OR block everything works as i expect it to work. But, you know, it's just confusing that i need to repick everything after OR block with false-picking condition.

    I still think that it's not quite right to don't pick any object's instances at all, and don't apply actions for that object, if in OR block the picking condition for this object is not True, even if other conditions is True.

    Even if this won't be fixed, it should be stated in the manual, that if in OR block you got False-picking condition, the object from that condition won't be picked at all in the whole event and it's sub-events, and actions for that object will not apply before you re-pick it again.

  • I've read the manual again, it's by design. Guess i have to re-pick everything after the OR blocks.

    [quote:bng8xvb3]Note that because OR blocks run if any condition is true, it's possible the event will still run if some conditions were false and did not pick any instances. In this case the actions will still run, but possibly with zero instances picked for any objects where no instances met the condition. If any actions are run for objects with no instances picked, nothing happens.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Closing as by design. One unexpected aspect of OR blocks is, in order for them to work correctly at all, they must be able to run with possibly zero instances selected for a type. "Layer 1" is invisible and it's in an OR block so the event is definitely going to run its actions based off that alone. The next condition tests for sprites which have var = 1, and none do. So the event engine picks zero of those instances and proceeds to run the actions. The actions run for all picked instances, so the Sprite action runs zero times and Sprite2 was not referenced so runs for all instances (once in this case).

    Note if you saw Sprite rotating, it would contradict the fact you have a condition that says it should not rotate.

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