To implement WASD movement in GameMaker, you will need to use GameMaker Language (GML) to check for keyboard input and move an instance (such as the player character) accordingly. Below is a simple code example that you could put in the Step event of your player object to achieve basic WASD movement.
This code checks if the keys 'W', 'A', 'S', 'D' are pressed and sets
move_y accordingly. If both
move_y are non-zero (i.e., the player is moving diagonally), their values are multiplied by approximately
0.7071 to ensure that the player's diagonal movement speed is consistent with their horizontal and vertical speeds.
keyboard_check() function returns
true if the specified key is being pressed and
false otherwise. The
ord() function converts a character to its ASCII value, which is necessary because
keyboard_check() expects a numerical key code.
y coordinates of the instance are updated by adding the product of the direction (
move_y) and the
move_speed. This moves the instance in the intended direction according to the player's input.