S
SilverTom93
Guest
At the moment, the basic platform physics of my game are going well (it uses arrow keys). I'm currently trying to implement an optional gamepad input into my game, which uses the joystick for moving left/right and the A button to jump. But whenever I press an arrow key AND a joystick direction at the same time, the movement speed of the player doubles...
So for example, if I'm using the left arrow key to move left, I move at a speed of 4. If I then hold the joystick in the same direction, it adds an extra speed of 4 on top of that. So it's basically giving the player a weird speed boost
Below are the first few lines of the player's Step event (the rest of the code I followed from this tutorial:
)
So that's basically saying "moving is when an arrow key is pressed, OR if the joystick is in a left/right direction"
Bear in mind that I'm still learning the basics of GML code, and there's most likely an incredibly simple solution to this which I don't know (much like in my last post XD) but if anyone knows a way to limit the left/right movement speed even if there's two buttons pressed simultaneously, then I'd be really thankful
So for example, if I'm using the left arrow key to move left, I move at a speed of 4. If I then hold the joystick in the same direction, it adds an extra speed of 4 on top of that. So it's basically giving the player a weird speed boost
Below are the first few lines of the player's Step event (the rest of the code I followed from this tutorial:
Code:
/// Platform Physics
var rkey = keyboard_check_pressed(vk_right) || (gamepad_axis_value(0,gp_axislh) > 0);
var lkey = -keyboard_check_pressed(vk_left) || (gamepad_axis_value(0,gp_axislh) < 0);
var jkey = keyboard_check_pressed(vk_up) || (gamepad_button_check_pressed(0,gp_face1));
Bear in mind that I'm still learning the basics of GML code, and there's most likely an incredibly simple solution to this which I don't know (much like in my last post XD) but if anyone knows a way to limit the left/right movement speed even if there's two buttons pressed simultaneously, then I'd be really thankful