How do I detect first pressed buttons?

0 favourites
  • 3 posts
From the Asset Store
A set of retro 16-Bit Neon UI elements to make your menus pop!
  • Hi, I'm building a multiplayer quizz game.

    For the moment I use keyboard as quiz buzzer for the example.

    So what I do is that when user press the buzzer, I increment an index. SO the first to press will have index at 1, second to press will have index at 2 etc...

    It was doing the job but then I realise that the first button I will check, in case of almost simultaneous press, will always be first.

    How can I assure that the fourth button to check have same chances than the first one?

    C3p: https://drive.google.com/file/d/1o8E5YEPF7NfHtdlYIhXTBD9EOCz0n59t/view?usp=share_link

    (like here, if you press A,Z,E,R at the same time, you'll see that A is always first, if you move R check first, R will be first...)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • So what happens is that Construct checks the events from top to bottom and because you are using none trigger condition like "Key is Down" they will be checked in order from the First "A" to your last "R", the "Triggers conditions" the one that has normally the Green arrow get called only when they get triggered and if I remember correctly if multiple Triggers are triggered on the same tick they will be run Top to Bottom swell.

    So to ensure that you have always randomness when multiple players press the button on the same tick then you gonna have to handle it differently, for example first check if more than one player is pressing the button and mark them, then just loop through those players randomly to assign a Rank to play.

    Here is an example:

    You can do it in multiple ways like pushing them into an Array and then picking them at random etc... I used here just a boolean to make it simpler just in case you haven't used Arrays yet.

    Also, I used a Family to simplify the code.

    https://www.dropbox.com/s/9cn7486s3nnqa9l/quizz2.c3p?dl=0

  • Great!

    Thanks a lot, i need to get more familiar with families.

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