How to Put Gravity Into GameMaker Studio

This is a step- by- step guide of how to put gravity into GameMaker

89 Views 1 Like
How to Put Gravity Into GameMaker Studio
13 Steps
Supplies
Embed
1
First of all, open the objects tab and select your main character (sprite). Add a step event so you can add actions to the sprite so it will move in a platform-like fashion.

First of all, open the objects tab and select your main character (sprite). Add a step event so you can add actions to the sprite so it will move in a platform-like fashion.

2
Go to the side tab marked Control, add the action Check Empty, and set "y" to 1. Also, check the Relative box.

Go to the side tab marked Control, add the action Check Empty, and set "y" to 1. Also, check the Relative box.

Recommended For You
3
Next, set the gravity and set the direction to 270. That action can be found in  the tab labeled Move. Don't forget to add an else event. Else can be found in control. This creates an if statement.

Next, set the gravity and set the direction to 270. That action can be found in the tab labeled Move. Don't forget to add an else event. Else can be found in control. This creates an if statement.

4
After adding the Else event, set both the gravity and the direction to 0. This will allow the game to understand that when it's collision free, there is a certain amount of gravity so you can jump.

After adding the Else event, set both the gravity and the direction to 0. This will allow the game to understand that when it's collision free, there is a certain amount of gravity so you can jump.

5
Add a Key Press event. Select it so it's Up. After that, add a check collision event and set "y" to 1. The event should be relative. The action can be found under Control.

Add a Key Press event. Select it so it's Up. After that, add a check collision event and set "y" to 1. The event should be relative. The action can be found under Control.

6
Since you are dealing with gravity, vertical speed is important! Depending on the game you want to make set the vertical speed. My vertical speed is -5. This action is under Move.

Since you are dealing with gravity, vertical speed is important! Depending on the game you want to make set the vertical speed. My vertical speed is -5. This action is under Move.

7
If you haven't created a collision event with an object wall (objWall), do so. The Move to Contact action is under Move. Set the direction to direction and the maximum to 12 against solid objects.

If you haven't created a collision event with an object wall (objWall), do so. The Move to Contact action is under Move. Set the direction to direction and the maximum to 12 against solid objects.

8
Don't forget to add a small piece of code! Type in : move_speed=5; This will allow you to move at a speed of 5 everywhere you go.

Don't forget to add a small piece of code! Type in : move_speed=5; This will allow you to move at a speed of 5 everywhere you go.

9

If you have the events: Key release Up, Down, Right Left, Keyboard Up or Down, please delete them. If you keep them, it won't look like a game with gravity, the sprite will seem to be in a maze game.

10
The next step is to put -move_speed as x and to check it as relative. This will allow you to move left relative to if there is a collision.

The next step is to put -move_speed as x and to check it as relative. This will allow you to move left relative to if there is a collision.

11
Next, add a Jump to Position action. It is found under the Move tab. make x -move_speed and make it relative. This will allow the sprite to move back and forth.

Next, add a Jump to Position action. It is found under the Move tab. make x -move_speed and make it relative. This will allow the sprite to move back and forth.

12

Do the same to the keyboard right action except instead of -move_speed, its move_speed. This would help move the sprite back and forth to jump.

13

Enjoy your GameMaker game with gravity! :)

keyboard shortcuts:     previous step     next step
Comments
0 COMMENTS
View More Comments