How to Add Gamepad Controls to your Game

preview_player
Показать описание
Learn how to add gamepad support to the Space Rocks game in GameMaker using GML! We’ll walk through detecting gamepads, handling movement, shooting, and combining keyboard and gamepad inputs. Perfect for those new to coding in GML!

#gamemaker #gml #tutorial #gamedevelopment #gamedeveloper

What is GameMaker? 👀
-----------------------------------------------------
GameMaker is the industry’s premier 2D game engine, used by thousands of developers every day to create indie gaming classics like Undertale, Hyper Light Drifter, and Chicory: A Colorful Tale.

It’s completely free to download and keep forever, with dozens of written guides and video tutorials to help you bring your games to life.

When your project is complete, you can publish your creations to all major platforms, including PlayStation 5, Xbox Series X|S, and Nintendo Switch.

Рекомендации по теме
Комментарии
Автор

You download input 8 and follow the setup guide. Somewhat joking aside thanks for the official tutorials I didn't know you guys were doing these.

LuigiXHero
Автор

I'm using GM Studio 1 and it doesn't have array_push function. What is the equivalent of it?
Also, my character uses WASD to strafe in all four directions so your "_move" variable won't work in my case. I would need to create 4 different variables for each direction: _move_up = keyboard_check(ord('W')); etc.

ivanshiek
Автор

is there a similar working method for 1.4?

SonneBenji
Автор

We need dinput vibration/led support on Windows!!

elbananita
Автор

my ipega controller when i conect it via usb it doesnt work and i mut add ai fix becuse it shows somthink like var =hdqyg38y44 = keybord pressed ord w and idk why it dont work my step script // Input: Keyboard
var _move = keyboard_check(vk_up);
var _hor = keyboard_check(vk_right) - keyboard_check(vk_left);
var _fire =

// Input: Gamepad (if connected)
var _gp = global.gamepad_main;
if (_gp != undefined) {
_move = gamepad_button_check(_gp, gp_shoulderrb); // move forward with shoulder
_hor = gamepad_axis_value(_gp, gp_axislh); // left stick horizontal
_fire = gamepad_button_check_pressed(_gp, gp_face1); // A button
}

// Movement
if (_move) {
motion_add(image_angle, 0.1 * _move);
}

if (_hor != 0) {
image_angle -= 4 * _hor; // rotate
}

// Screen wrapping
move_wrap(1, 1, 0);

// Firing
if (_fire) {
var bullet = instance_create_layer(x, y, "Instances", obj_bullet);
bullet.direction = image_angle;

audio_play_sound(shoot, 0, 0, 1.0, undefined, 1.0);

if (powerup == 1) {
var bullet1 = instance_create_layer(x, y, "Instances", obj_bullet);
bullet1.direction = image_angle + 10;

var bullet2 = instance_create_layer(x, y, "Instances", obj_bullet);
bullet2.direction = image_angle - 10;
}

if (powerup == 3) {
// Placeholder for powerup 3 effect
}
}

randomes_shorts
visit shbcf.ru