0 Favourites

How do I "OR"

  • how do I add an OR statement to an event?

    my dilemma is I have 8 "On Keyboard" events that each have 3 conditions. I know I could simply reproduce these with the "On Touch" event, but this would give me 16 events. If I could add an "OR" statement eg. "On Keyboard OR On Touch" It would reduce my number of events, reducing my final file size.

    another way that i think i could achieve this would be "On Touch" -> Simulate "On Keyboard" like you can for "On Touch" -> Simulate "8 direction" but I cant find a way to do this either.

    I know a lot of you will say "why not use 8 direction movement?" the reason for this is I am designing my own grid based movement system

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • How events work scroll down to or block.

    Right click event in left corner and Make 'Or" block

  • Start with an On Key Pressed trigger, or any key is down, depending on your needs. Then as a sub-condition use the system Compare Two Values expression. In the top line enter your 3 keyboard conditions separated by " | " (remove quotation marks). Like:

    Keyboard.LastKeyCode = 50 | Keyboard.LastKeyCode = 51 | Keyboard.LastKeyCode = 52

    These are the conditions you are "OR" checking for one of them to be TRUE, so the rest of the Compare Two Values should be "= 1 ", where 1 represents TRUE.

    I personally use player control variables (booleans) where I set these to true or false at the start of the player control layout, so when I need to check if a control input is made I just check the single variable rather than repeating all of the above code.

  • thanks guys got this working now

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