8-Directional Movement in gamemaker studio

Let’s look at making a character move in 8 directions!


					var _left = keyboard_check(vk_left);
var _right = keyboard_check(vk_right);
var _up = keyboard_check(vk_up);
var _down = keyboard_check(vk_down);
var _hspd = _right - _left;
var _vspd = _down - _up;


					var _left = keyboard_check(ord("A"));
var _right = keyboard_check(ord("D"));
var _up = keyboard_check(ord("W"));
var _down = keyboard_check(ord("S"));
var _hspd = _right - _left;
var _vspd = _down - _up;

Choose one of the two options.

The first option uses [ARROW KEYS] and the second option uses [WASD]


					if (_hspd != 0 || _vspd != 0)
    var _spd = 4;
    var _dir = point_direction(0, 0, _hspd, _yspd);
    var _xadd = lengthdir_x(_spd, _dir);
    var _yadd = lengthdir_y(_spd, _dir);
    x = x + _xadd;
    y = y + _yadd;

After adding the following code to your player in the room editor, you can now move your player!


For a more in-depth tutorial, click HERE.


Sometimes we don’t fully explain things as well as you might want. Not to fear! We will answer all of your questions regarding any tutorial. Fill out the form below and we will try to reach back out to you as quickly as possible. Expect to hear a response within one week. For an instant response, join our discord server.


Leave a Reply

Your email address will not be published. Required fields are marked *