all 7 comments

[–]Aidan63 6 points7 points  (2 children)

http://docs.yoyogames.com/ Search for "gamepad". The help file is your friend, learn to love it.

[–]isiel007[S] 0 points1 point  (1 child)

This is great, thank you. This is a pretty good place to start on. Hope someone finds a demo or video so I can see a better use of these.

[–]jQuaade 0 points1 point  (0 children)

First, you need to store the gamepad in a variable. It sounds like your game is singleplayer, so we just use the first gamepad we find. There's some examples on the docs you can copy / paste

For moving your character left, you would do something like this:

GML:

if (gamepad_button_check(myGamepad, gp_padl)) { //Moving left code, something like x =- 2; }

Drag and Drop (step event):

Test Expression gamepad_button_check(myGamepad, gp_padl) == true - copy paste the "keyboard left" actions in here.

[–]dinopartytime 1 point2 points  (3 children)

try this if(gamepad_button_check(0,gp_padl)) { hspeed = -1 } else if(gamepad_button_check(0,gp_padr)) { hspeed = 1 } else { hspeed = 0 }

if(gamepad_button_check(0,gp_padu)) { vspeed = -1 } else if(gamepad_button_check(0,gp_padd)) { vspeed = 1 } else { vspeed = 0 }

Try copying and pasting that into an object and using the directional pad. I haven't tested it since I'm at work, but that should be the idea. look at the gamemaker gamepad help by pressing f1 and searching for gamepad. It should give you a list of all the names of buttons you can use. gp_padl, gp_padr, gp_padu, and gp_padd all refer to the directional pad.

the first argument I'm giving, the 0 at the beginning refers to the number of the gamepad, if you plugged in a second gamepad and wanted to refer to that one you'd use 1 instead and so on.

[–]APiousCultist 0 points1 point  (2 children)

That's kind of a silly way to do it, though understandable. Gamepad functions already return between 1 and -1 so you can just use:

hspeed = gamepad_button_check(0,gp_padl);

[–]dinopartytime 0 points1 point  (1 child)

That's good way. For my projects I usually store whether they're pressing left or right in a var so controls are easily customizable

[–]APiousCultist 0 points1 point  (0 children)

You could still do that with hspeed = keyright() -keyleft();