Change Controls at Run Time

This forum is currently in read-only mode.
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • So this is literally the last thing I have on my "to do" list before uploading my game for beta testing. Everything else is done, and I figured this would be fairly easy. Depending on the value of a "Controls" global variable, I would have the game respond to different keys for the basic controls. WASD movement, or arrow key movement.

    However, I can't see any way of changing the controls settings through events. And running a forum search for the topic led to recommendations for using this plugin: http://www.scirra.com/forum/customcontrols-works-new-demo-cap-fixes-360-analog-problems_topic38157_page6.html Which hasn't worked for over two years!

    Is there any other way to do this? Is it supported in-game now, and I'm just missing something?

    Thanks for reading <img src="smileys/smiley12.gif" border="0" align="middle">

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yes, this can be done. However, just a question; but would it clash with anything you're doing if you just had both controls activated? Then the user could just decide on the fly what controls he wants to use, and you wouldn't need to have a menu just for that.

  • It would, yes. If I handled it the way I have planned. I was going to use three different control options:

    WASD Movement, Arrow Keys for abilities (four different elemental abilities)

    Arrow Key movement, numbers 1 to 4 for abilities

    Arrow Key movement except spacebar to jump instead of the Up Arrow, numbers 1 to 4 for abilities

    I've have pondered the idea of allowing the player to set his own keys for each action, but that all depends on how much time it would take to implement.

  • Though having said that, if there's a way to make the spacebar function as a jump button as well as another button (W or Up Arrow) then I can condense that down to two options instead of three <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Oh, I see. I may have a .cap for you. I'll be back shortly to report whether I do or not.

  • Thanks man <img src="smileys/smiley1.gif" border="0" align="middle" />

    I'm going to call it a night for now, but hopefully I can get this final hurdle cleared tomorrow and let people play the game! I've just found I have issues with the High Score implementation as well, but I have a solution to work around that for now. Finding a way to change controls at run-time is the last thing I need to do!

  • Here is the .cap:

    rapidshare.com/files/4170808448/ControlsMenuForSilverFinal.cap

    I'm not sure of how you have your controls set up so I have it set for left and right movement. You'll have to add in the specifics of your setup, but the foundation of activating and deactivating control types at runtime based on a setting are in the .cap. The .cap has two control types (WASD and Arrows); "other" has no function, but it is already attached to a global variable so you can attach events for another control setting to it.

    To use: Run the "Control Settings" layout.

  • Ahh, the trouble with handling it this way is that (as far as I'm aware) there's no way to handle acceleration, deceleration, jump sustain, etc. It would completely change how the game handles when you change the control layout.

    Man, that's a shame. I guess I'll just have to go with arrow key movement, and abandon the control options idea <img src="smileys/smiley6.gif" border="0" align="middle" />

    Thanks for the suggestion though! There might be a way to pull it off with this method, but it would likely involve scripting out huge chunks of Construct's platform behaviour from scratch. I can't believe this option isn't included as standard.

  • Well, with the platform movement object already attached, you can still set acceleration, deceleration, and jump sustain just like you normally would for the arrow keys, so that's no problem. It works easily because Construct is already set to have the platform movement work with the arrow keys by default.

    But I'm wondering if just switching player control commands might do the trick. Like, if the global global variable 0 it would activate player 1's controls that are WASD keys and disable player 2. And if the global variable is 1 it would activate player 2's controls that are Arrow keys and disable player 1. If it's a one-player game you'd be using the same keyboard for both player settings.

    ... I dunno just an idea, I've never actually tried it before.

  • But I'm wondering if just switching player control commands might do the trick. Like, if the global global variable 0 it would activate player 1's controls that are WASD keys and disable player 2. And if the global variable is 1 it would activate player 2's controls that are Arrow keys and disable player 1. If it's a one-player game you'd be using the same keyboard for both player settings.

    ... I dunno just an idea, I've never actually tried it before.

    Woah, that's an awesome idea. I'll give it a spin! Thanks for the suggestion <img src="smileys/smiley4.gif" border="0" align="middle" />

  • If you try it and can get that to work, please post an example .cap, because I'm very interested in how well this would operate.

  • Will Do <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Silver, I believe I've got it. Check this out:

    -I took a sprite and attached two platform objects to it.

    -For the first platform object I set the "Control" name as "Player 1". For the second platform object I set the "Control" name as "Player 2".

    -I then went into the Properties menu and went to the "Controls" sub menu and set the controls for Arrows keys for Player 1 (P1), and then set the controls for WASD for Player 2 (P2).

    -I then created a Global variable called "Controls"

    -I then went into the event sheet and created the following events in order to test it:

    <img src="http://farm9.staticflickr.com/8484/8263070546_128634e0b7.jpg" border="0" />

    .Cap = rapidshare.com/files/3520367228/WASD-Arrow%20Movement.cap

    Press '0' for Arrow control. Press '1' for WASD control (I only put W, A, and D in, you can fill in the rest with what you need).

    It works.

  • I think I love you <img src="smileys/smiley27.gif" border="0" align="middle" />

    Took quite a long time to reorganize and amend my event sheets to account for three different Player sprites, but it works perfectly.

    If I was the King of England I'd offer you a Knighthood. Sadly, I'm not, so a simple thank you will have to suffice <img src="smileys/smiley1.gif" border="0" align="middle" />

    Cheers Mr. Miller, I really appreciate the help!

  • I have to say that after the day I just had your message really changed the whole mood of it to positive. I really needed that!

    Like I said from the beginning, I think you're onto something with this game. There is just something interesting about that wolf, and I'm looking forward to seeing how it all unfolds.

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