The direction of the object's motion, in degrees.


GML Code Example


Returns: Real


All instances in GameMaker: Studio have certain "built in" properties that you can use and set to govern how they look and behave. Direction is one of those properties and can be used to set the direction of movement of the instance when the instance has a speed other than 0. Note that directions in GameMaker: Studio are usually calculated as 0° being right, 90° being up, 180° being left and 270° being down.


GML Code Example

if keyboard_check(vk_left) direction += 5;
 if keyboard_check(vk_right) direction -= 5;

The above code will change the direction of movement of the instance based on which key (left or right) is pressed.

Next: friction

These examples are submitted by the community. Upvote the examples you think are most helpful.

direction towards mouse by /u/tmcicuurd12b42 on January 19, 2017

GML Code

speed = 4;

direction = point_direction(x,y,mouse_x,mouse_y);


See It In Action:

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here