How do I create a rebindable controller system?

0 favourites
  • 3 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • This code sets individual bits in an array, at positions corresponding to gamepad button index, to 1/0 when the button is pressed/released respectively. But the problem is that when multiple buttons are pressed at the same time or in quick succession, certain bits will become stuck at 1. I'm guessing that this is because gamepad.LastButton is changed when the next button is pressed, so if one button is pressed while another is released, then one of the bits won't update.

    As you can see, my attempts to resolve the problem have only become more convoluted and more broken as time goes on.

    Can anybody think of a solution to this problem?

    ( Here's the .capx, if you'd rather look at it that way: https://www.dropbox.com/s/lonh0dkzd9ugq ... .capx?dl=1 )

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Virtualistik

    I'm not sure why you had the set bit code in your input array. As soon as I took it off it seemed to work. Here check out my reworked example. The only thing I could see you having a problem with is trying to rebind the analog sticks. I'm not sure how that would be done. I'ld have to think about it. But I don't know if that's something you wanted.

    In the example click one of the Control buttons in the ui that you want to bind than click a button on your gamepad to bind it.

    What you would do is preload the array with the default bindings.

  • Thanks man. I dunno why I was so obsessed with the idea of setting each controller button to be represented by a single bit in a number. Your way works a lot better.

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