Jumping

GML
// Jumping if (jumping == 1) { jumptime += 1; if (jumptime <= 5) {vspeed = -17} if (jumptime > 5) { if (jumptime <= 10) {vspeed = -12}} if (jumptime > 10) { if (jumptime <= 15) {vspeed = -7}} }

Provided there’s nothing underneath our man, increase his vspeed up  until  a  certain maximum falling  speed. When you press jump  (and you’re standing on something) don’t simply momentarily  set  vspeed  to a negative  value  but instead as long as that jump button is pressed have a timer increase, and set your vspeed accordingly. It’s very simple code but many  GM  games miss it. Different values  for different times means you can still incorporate a decrease in upwards speed but not have it nearly as much as your usual gravity. Make A little note about using “if…” within another  “if…”, unless you have to use an “else” statement afterward it’s much better than using “&&” because if the first statement is not  true  the  computer  doesn’t  have  to  read  anything else. It may seem small but over the whole code of your game it does make a sizable efficiency gain.

Drag and Drop
Drag & Drop is the easiest way.


 * 1) Make a collision event with the ground object.
 * 2) In the control tab, drag in the gray block that says VAR.
 * 3) Set the Variable info like this : variable: jumpon value: 1
 * 4) Now in the event where the jump key is pressed, drag in the VAR test event. (a blue octagon with VAR on it)
 * 5) Set it like this : variable: jumpon value:1
 * 6) Make sure what you want to do is in start and end blocks and the VAR actions are before it.