Custom Controller Key Mapping Problem — How Do I Fix It?

Not favoritedFavorited Favorited 0 favourites
  • 11 posts
From the Asset Store
Two types of minimap: "full map" and "player is the center" (square map and radial map)
  • Hello everyone, I created a key binding section for my game like the one in the picture. The assigned keys work fine in the game. The problem is that I can assign the same key to another action. When that happens, both actions become inactive. By the way, I don’t have much coding knowledge. What’s a simple way to prevent this? I’d really appreciate your help.

  • Hello everyone, I created a key binding section for my game like the one in the picture. The assigned keys work fine in the game. The problem is that I can assign the same key to another action. When that happens, both actions become inactive. By the way, I don’t have much coding knowledge. What’s a simple way to prevent this? I’d really appreciate your help.

    Is there anyone who can help?

  • It's hard to tell exactly from a screenshot, but I'd start by running the debugger and seeing what your dictionary looks like in the inspector at every step.

  • It's hard to tell exactly from a screenshot, but I'd start by running the debugger and seeing what your dictionary looks like in the inspector at every step.

    Thank you Citron2010 . I already checked it there first. I can assign a key that is already bound to another action to all the other actions as well. How can I prevent this or implement a key swap between actions?

  • This should prevent double values.

  • This should prevent double values.

    Thank you very much for your help, Asmodean . It's working.

  • This should prevent double values.

    I tested it. It works perfectly. Thank you for your help, Asmodean.

    My last question is about gamepad controls. :)

    How can I adapt my current system to gamepad input? Unlike the keyboard, if a button assigned to one action is already used for another action, I would like to apply a switch logic between the two instead of adding new button mappings.

    Thank you in advance for your help. :)

  • I hope that works, it should:

    (Ignore the DefaultButton Dictionary, that was another idea)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I hope that works, it should:

    (Ignore the DefaultButton Dictionary, that was another idea)

    Thank you Asmodean.

    I tried. But unfortunately, as seen in the picture, there is a conflict between the keys. :(

    Am I missing something? It swaps two keys together. But I think it doesn't matter if one of those keys is on the other keys that isn't swapped.

  • Change tempButton variable to number at the moment it's a string. You have to make a new variable and replace it in the events then delete tempButton and rename the new one.

    I hope that was the problem. It works for me now.

    And you have to clear the local storage otherwise you will have the wrong dictionary with double entries. You could use clear storage once and delete it then.

    + System: On start of layout

    -> LocalStorage: Clear storage

    I forgot also to save the dictionary in the else under the is noDouble

    + System: Else

    -> LocalStorage: Set item "ButtonBindings" to ButtonBindings.AsJSON

  • Change tempButton variable to number at the moment it's a string. You have to make a new variable and replace it in the events then delete tempButton and rename the new one.

    I hope that was the problem. It works for me now.

    And you have to clear the local storage otherwise you will have the wrong dictionary with double entries. You could use clear storage once and delete it then.

    + System: On start of layout

    -> LocalStorage: Clear storage

    I forgot also to save the dictionary in the else under the is noDouble

    + System: Else

    -> LocalStorage: Set item "ButtonBindings" to ButtonBindings.AsJSON

    Thank you very much Asmodean.You were very helpful. It works now. :)

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