Odd Behavior with Or block

  • I had a pickup object on which I wanted to call a function "pickup()" if the player rolled over it with the mouse OR after an on timer event on that object. I set up both events and tested them. They both worked:

    When I combined them into an OR block, it would only work on the first event in the block. If I switched the order, the first would always work, but it would never trigger if the second event in the Or block was triggered.

    Is there something obvious I'm missing here? Are there any known issues with Or blocks? Or is checking for a cursor over an object somehow incompatible with checking for an on timer event? Both seem impossible, yet... it doesn't work. I have Or blocks all over the place that work, so I'm pretty sure it's set up properly...

  • Timer is a Trigger. You can not combine it like regular events. Given that you just call a function anyway, there is no need to use an OR, just separate the events.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Interesting. Is there a list of "triggers"? Thanks for the quick reply!

  • Anything with a green arrow, typically named "On XXX".

  • Timer is a Trigger. You can not combine it like regular events. Given that you just call a function anyway, there is no need to use an OR, just separate the events.

    I believe that's not true. The trigger should work in this situation with regular events like expected. The manual entry for OR blocks even use triggers as examples.

    I suggest posting a capx with a simple reproduction so it's possible to tell if it's really a bug in C2 or some other events are interfering with your project's logic.

  • Oh weird. It does seem like something that should work. It's just a check.

    I'd rather not post my entire game capx. It seems an easy thing to reproduce in a couple of steps? The only behavior on my "cigarette" object is the timer. Both events work fine alone or if they are the first event in the "or" block.

  • Manual: "Also note normally you can only put one trigger in an event, but you can put multiple triggers in an 'Or' block, and the event will run if any of triggers run."

    It depends on the usage. Triggers run outside of the normal event loop, so you do have to be careful of combining with other events.

  • That's right, triggers don't follow the execution order like regular events. They act like traditional programming events that are only executed at the exact moment they happen. But that has no relation to the OR block, it should work normally like the manual transcription you quoted.

    I did a test and strangely that particularly combination of events are acting like an AND instead of an OR. It does seem like a bizarre bug, here's a capx:

    C2 OR bug

    • Try to click outside the square, the flash doesn't trigger.
    • Try to hover the mouse on the square, the flash doesn't trigger.
    • But if you hover and click the square the flash triggers.
    • Next enable the other blocks and disable the previous to see how they behave differently.
  • That seems like different behavior than I was seeing. For me it was executing on only the first item in the block as if the second wasn't there. Bizarre.

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