gravity

The gravity to apply to the object.

Syntax:

gravity


Returns: Real


Description

All instances in GameMaker: Studio have certain "built in" properties that you can use and set to govern how they look and behave. Gravity is one of those properties and, when set, will apply a constant force in the gravity direction of the instance, influencing its speed. Note that gravity is a cumulative force and will accelerate the object if you choose not to cap the final speed.


Example:

if !place_meeting(x, y + 1, obj_Ground)
   {
   gravity = 0.01;
   }
else
   {
   gravity = 0;
   }

The above code will only apply gravity if the instance does not find any instances of "obj_Ground" beneath it.


Back: Moving Around
Next: gravity_direction
© Copyright YoYo Games Ltd. 2018 All Rights Reserved