GameMaker Studio 2 Desktop

GameMaker Studio 2 Desktop

Wickerman Jun 21, 2020 @ 11:16pm
Gamepad Help!
hi, i'm completely new to GMS 2 and need your help!
I am following Shaun Spalding tutorials on Youtube and as far as i can tell, have followed his code exactly.
I have hit a brick wall now though on part 5 ( Gamepads/controllers)
I have tried everything to connect my Xbox one wireless controller and PS 3 wired controller to move my player but nothing seems to work.
Both my controllers work fine on Windows 10.
I have tried changing the Xinput from 0 to 1,2,3,4 without success.
here is my player object step event code:

//get player input
key_left = keyboard_check(ord("A"));
key_right = keyboard_check(ord("S"));
key_jump = keyboard_check_pressed(vk_space);

if (key_left) || (key_right) || (key_jump)
{
controller = 0;
}

if (abs(gamepad_axis_value(0,gp_axislh)) >0.2)
{
key_left = abs(min(gamepad_axis_value(0,gp_axislh),0));
key_right = max(gamepad_axis_value(0,gp_axislh),0);
controller = 1;
}

if (gamepad_button_check_pressed(0,gp_face1))
{
key_jump = 1;
controller = 1;
}

//calculate movement
var move = key_right - key_left;

hsp = move * walksp;

vsp = vsp + grv;

if (place_meeting (x,y+1,owall)) and (key_jump)
{
vsp = -7;
}


//Horizontal Collision
if (place_meeting (x+hsp,y,owall))
{
while (! place_meeting (x+sign (hsp),y,owall))
{
x=x+sign (hsp);
}
hsp =0;
}
x=x+hsp;

//Vertical Collision
if (place_meeting (x,y+vsp,owall))
{
while (! place_meeting (x,y+sign (vsp),owall))
{
y = y+sign (vsp);
}
vsp = 0;
}
y =y+vsp;

//animation
if (!place_meeting (x,y+1,owall))
{
sprite_index = splayerA;
image_speed = 0;
if (sign(vsp) > 0) image_speed =1; else image_index = 0;
}
else
{
image_speed = 1;
if (hsp ==0)
{
sprite_index = splayer;
}
else
{
sprite_index = splayerR;
}
}
if (hsp != 0) image_xscale= sign (hsp);

Any help would be greatly appreciated thank you!
< >
Showing 1-4 of 4 comments
Wickerman Jul 4, 2020 @ 11:06pm 
Can anybody please help?
I'm desperate to learn.
johnmc50 Jul 9, 2020 @ 6:03pm 
I have a hunch why, lets try an idea.

I have a hunch game pad might night be compatible

here is how you check it

place a game dvd for xbox or ps3 game machine

and try the same game pad, if it does not work then

it's not compatible.

----------------------------------------------------------------------------

I thought that possibility because i tried a ibm key board

to my tv usb port so i could type in search window.

i just tab s

here is what happen s s s s

so i figure same idea
-----------------------------------------------------------------------------------------

good luck

Wickerman Jul 9, 2020 @ 10:58pm 
I finally figured it out.
The code was fine, it was because i was running GM through steam and not directly from YOYO.
It must of been screwing with my controller.
Thanks for the reply.
[NORA]NekoNyan Feb 17, 2022 @ 1:41am 
I had the same problem. I solved it Thank you:slimetabby:

Originally posted by Wickerman:
I finally figured it out.
The code was fine, it was because i was running GM through steam and not directly from YOYO.
It must of been screwing with my controller.
Thanks for the reply.
< >
Showing 1-4 of 4 comments
Per page: 1530 50