How do I let user customize controls?

0 favourites
  • 12 posts
From the Asset Store
Project File of my C3 Tutorial Customized DropDown List
  • I'm working on adding custom controls to my game...beacuse I hate when developers lock you into their button layout.

    Anyway, it occurs to me that this must have been discussed before, included in a tutorial, etc...but my searching isn't getting anywhere.

    In particular, I'm having a bit of trouble coming up with an elegant solution to custom map mouse buttons. With the keyboard I can just store keycodes in global variables like "keycode_foo", then "On keycode (keycode_foo) pressed".

    However, there is no "On (keycode_foo) mouse button clicked" action, and all I'm coming up with is awkward, convoluted event trees.

    Cheers, T

  • Not sure if this will help you, but it might..

    It's meant to turn Keyboardinput into the numbers on the NumPad..

    so to check if a key is pressed and the mousebutton is pressed at the same time would be rather easy (But I might have totally misunderstood your question)

  • Sorry, but that's not quite what I'm after. Trying to come up with a good way to alias any mouse button to any control.

    With the keyboard, I can store keycodes in global variables (or an array) and then have "On keycode (keycode_foo) pressed" events. When these are true, I set a global var to 1. So

    On keycode Keycode_Attack pressed:

    Set ControlDown_Attack to true

    However, there is no equivalent "On mouse button (mousecode_foo) pressed" action. Instead I have to do:

    On left/middle/right click

    Set ???

    With the keycode solution, I know what the user is trying to do by the name of the keycode var, and I know they are pressing the right key by evaluating it's value. But...how do I handle that for the mouse? All I can tell is when the the different mouse buttons are down...I have to figure out what said buttons are supposed to do with other logic.

    I can think of a couple ways to do it, with functions or groups, but my approaches seem overly complicated. I can't help but think "Ockham's razor...you are missing something."

  • couldn't you just add a variable mousebutton or something and make actions based on that variable..

    there's only three mousebuttons, so creating an event to change the mousebuttonvariable based on user preferences shouldn't be hard..

    It seems to me to be that easy, but I might be overlooking something?

  • Call back referenes. Personally I like to use a dictionary. There is a tutorial. but it's all about knowing the keywords to use.... but you won't know them until you found the tutorial in the first place

    The gist is

    step. 0

    [---Group Assign Function(active)----]

    OnAnyKeyPress

    ->Dictionary.Add( "Press" & keyboard.lastkey, FunctionToAssignSelection.FunctionAbility)

    -> Deactivate Group Assign Function

    step. 2

    on any key pressed

    -> Function.Call( Dictionary.Get( "Press" & keyboard.lastkey), whatever holds paramaters )

    step 3. on saving of setp

    WebStorage.Set( "controller setup", Dictionary.ToJson )

    step 4. on loading setup

    Dictionary.FromJson( WebStorage.Get("controller setup") )

    and that's the basics. do the same for mouse, joysticks so on etc.

  • LittleStain

    Essentially, but I want a system with a little more flexability...jayderyu makes a good suggestion.

    jayderyu

    Never thought of that...much better than triggering a bunch of functions or groups by name. Will also make it easier to load control setups in/out from text files, etc. Thanks!

  • Can someone go more in depth about what jayderyu posted please?

    It would be really good if the player in my game was able to change their buttons and I want to learn how to do it but I am unsure about how to do it exactly what jayderyu posted.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Can someone go more in depth about what jayderyu posted please?

    Actually that is already in-depth, and a good answer. Take time to browse through manual based on what he said, I guess you should be good.

    It always better if you ask specific question though.

  • i have makes project what you are need (I think). My Friend asking same problem. I work midnight, but i have done and get result!

    this is my project: http://c2tuts.tk/project/ChangeControll/

    and this is download link: https://drive.google.com/uc?export=down ... GJDeERjWnM

    There are using my country language (Indonesia, Melayu). So, if you dont understand just click "jump" or "move right" then press your keyboard key you want. Sorry for my english.

    I hope this help!

    Regards,

    -Regga354

  • Regga354 So far it works perfectly. Thanks so much. This is really cool.

  • Regga354 So far it works perfectly. Thanks so much. This is really cool.

    thank you

  • Regga354

    Thanks for the example! I'll check it out too.

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