[TUTORIAL] Change the gravity (and air resistance)

Started by Mortimer Kerman on Sun, 06/20/2021 - 09:01

Topic category: User side tutorials

Last seen on 22:08, 3. Aug 2021
Joined Aug 2020

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
[TUTORIAL] Change the gravity (and air resistance)
Sun, 06/20/2021 - 09:43 (edited)

Hello, in this short tutorial, I will show you how to change the gravity of the player or an entity of your choice. It works in all versions of MCreator, although I made the images in 1.12. Small interface differences are therefore to be expected. First, you must add in a procedure of your choice which will have to launch on player update tick or of an entity of your choice (even a potion if you want) this code:


you can use any trigger conditions you want, for example detect if the player is on a custom dimension.

Firstly, you will need to choose the gravity. It can be stronger or weaker than normal gravity.

For this tutorial, I will use 25% of Earth's gravity.

Warning: If you put values lower than 4% of Earth's gravity, the player will be stuck in the air.

To calculate the gravity value, you need to calculate the percentage of 0.08 based on the gravity you want. In my case, I will therefore calculate 25% of 0.08, which gives me 0.02.

Replace the number 1111 in the procedure with your result.


Then you can change the air resistance if you want. You will therefore have to choose a number between 0 and 1. If you choose 0, the player will no longer be able to move vertically. If you choose 1, there will be no more friction, as if the player is in space.

Normal air resistance is 0.98.

For this tutorial, I will remove air resistance, so I choose 1.

Replace the number 2222 in the procedure with your value.


Then you just have to replace the number 3333 in the procedure with your gravity value (in my case, 0.25).


Now you can save and close the visual editor.

The last step will be to open the source code of the procedure and find this line:


Replace "motionY" with "fallDistance".


Now lock and save your code, and you can start the game!


And here is a gif of the result in game!


Edited by Mortimer Kerman on Sun, 06/20/2021 - 09:43