Help with an Or block

0 favourites
  • 10 posts
From the Asset Store
Merge Blocks - Full Game
$19.60 USD
60% off
Place blocks on a board, join them together to form even bigger blocks!
  • I have an issue using an OR block. Here is the code:

    When you press W, the player sprite gets sent to a dash state moving him forward. This works when the player is on the ground, however when you jump and push W, the player doesn't dash. It should dash because AirDash=1 right? If I delete the "Player is on floor" event, the player can then air dash as expected. Why doesn't it trigger with both conditions in the Or block?

    Here us the capx if anyone wants to check it out.

    Thanks for any help

  • C2 has always struggled with OR, as OR just doesn't fit well with C2's primary mechanism of 'picking'. The problem here is both conditions are run, but that means that the 'on floor' condition has now picked no objects, so by the time the code reaches the action, no Players are picked. To prove this, add a sub-event that does a pick-all on Player, and move your action there. You'll see it now works.

    I avoid OR generally, as it just doesn't work well when picking gets involved. Either split up the conditions, or work around the issue as explained here.

  • C2 has always struggled with OR, as OR just doesn't fit well with C2's primary mechanism of 'picking'. The problem here is both conditions are run, but that means that the 'on floor' condition has now picked no objects, so by the time the code reaches the action, no Players are picked. To prove this, add a sub-event that does a pick-all on Player, and move your action there. You'll see it now works.

    I avoid OR generally, as it just doesn't work well when picking gets involved. Either split up the conditions, or work around the issue as explained here.

    Well that's confusing. Thanks for the advice and workaround!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The actions run, as explained in the manual here:

    https://www.scirra.com/manual/75/how-events-work

    There is just no object picked.

    This is a the logic (not a workarround) if you would insist using 'OR' in a picking situation.

    https://www.dropbox.com/s/0fb3727hnew5r ... .capx?dl=0

    Personal i never us 'OR' when picking.

  • Or won't be working properly with overlapping condition. It would be better separate condition in different events for overlapping test.

  • The actions run, as explained in the manual here:

    https://www.scirra.com/manual/75/how-events-work

    There is just no object picked.

    This is a the logic (not a workarround) if you would insist using 'OR' in a picking situation.

    https://www.dropbox.com/s/0fb3727hnew5r ... .capx?dl=0

    Personal i never us 'OR' when picking.

    I did read the manual but it didn't click until blackhornet explained it. Just for clarity, does the OR not work because Platform on Floor = False so it clears the picking list?

    I'm staying away from OR as much as possible anyway now. It's a shame because it's much cleaner than separating the events and repeating the actions.

  • The OR works, however the SOL is devoid of any "Player", so no "Player" action can occur.

    Since you probably have only one player, I guess you could add a subevent with a "Pick all Player", and put your action in there.

    Like this :

  • I believe your problem may be in the values of the variables ...

  • Magistross

    That is a new construction 4 me, ty for sharing.

  • UberLou

    It is just how it works. C2 is mostly about picking.

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