Adro
Member
Hey there fellow game makers,
I'm new to using GamePads and I'm having some problems. I'm using really simple code to get my gamepad input, but it won't animate cleanly like the keyboard controls--in fact adding the GamePad input causes both inputs to lag.
My system and animation worked fine with just keyboard input, and will animated correctly if I negate the gamepad_set_axis_deadzone function, but then the obviously this creates a different type of broken.
Any suggestions would be much appreciated. I might need to overhaul whole my input system, but thought I'd check with others more experienced first.
Much thanks.
Obviously this isn't all of the exact code, this is just the left movement as an example of the system. Let me know if you need more code for better clarification.
Adro
I'm new to using GamePads and I'm having some problems. I'm using really simple code to get my gamepad input, but it won't animate cleanly like the keyboard controls--in fact adding the GamePad input causes both inputs to lag.
My system and animation worked fine with just keyboard input, and will animated correctly if I negate the gamepad_set_axis_deadzone function, but then the obviously this creates a different type of broken.
Any suggestions would be much appreciated. I might need to overhaul whole my input system, but thought I'd check with others more experienced first.
Much thanks.
GML:
// CREATE EVENT
}
// set up gamepad deadzone
gamepad_set_axis_deadzone(0, 0.5);
}
// STEP EVENT
if (state == states.idle)
{
player_speed = 0;
image_speed = 0;
// change states if direction is given
if (keyboard_check(vk_left) == true) or (gamepad_axis_value(0, gp_axislh) > 0) state = states.moving;
if (keyboard_check(vk_right) == true) or (gamepad_axis_value(0, gp_axislh) < 0) state = states.moving;
if (keyboard_check(vk_up) == true) or (gamepad_axis_value(0, gp_axislv) < 0) state = states.moving;
if (keyboard_check(vk_down) == true) or (gamepad_axis_value(0, gp_axislv) > 0) state = states.moving;
}
...
else if (state == states.moving)
{
// movement commands
if (keyboard_check(vk_left) == true) or (gamepad_axis_value(0, gp_axislh) < 0)
{
// set player speed and animation speed
player_speed = player_speed_normal;
image_speed = 1;
// check for collision
if (place_meeting(x-2, y, objSolid) == false)
{
direction = 180;
if (!strafing) sprite_index = LEFT_SPRITE;
image_speed = 1;
}
}
...
// change state back to idle
if keyboard_check_released(vk_left) or (gamepad_axis_value(0, gp_axislh) == 0) state = states.idle;
if keyboard_check_released(vk_right) or (gamepad_axis_value(0, gp_axislh) == 0) state = states.idle;
if keyboard_check_released(vk_up) or (gamepad_axis_value(0, gp_axislv) == 0) state = states.idle;
if keyboard_check_released(vk_down) or (gamepad_axis_value(0, gp_axislv) == 0) state = states.idle;
}
}
Adro