vspeed (Game Maker)


( Game Maker 6.1, 7 )

vspeed - vertical speed of an instance.


vspeed is a local variable that contains the current vertical speed of a an instance, in pixels per step. A negative vspeed will cause the instance to move up and a positive vspeed will cause the instance to move down.


Example of Use

vspeed = 1;

In this example, the instance will move 1 pixels down every step.

Limiting vspeed

if(vspeed > 20)
    vspeed = 20;
if (vspeed < -20)
    vspeed = -20;

If this is placed in a Step event, it will limit an object's vspeed to 20. See threshold.


From a game design perspective, jumping in a platform game is nothing more than setting the vspeed to a negative number so that the player object starts to move upwards. Eventually, gravity overcomes the initial vspeed, and the object starts to fall down.

gravity = 0.2;
    vspeed = 5;

Detecting Up/Down Movement

if(vspeed = abs(vspeed))
   //instance is moving down
  //instance is moving up

The code in this example will tell you if an instance is moving up or down during runtime.

Reversing vspeed

You can reverse the vspeed by multiplying it by -1. Note that 1 is the identity element of multiplication.

vspeed = vspeed * -1;

Useful Info

  • direction, if it is not set manually, is calculated by using the vspeed and hspeed of an object. If the hspeed and vspeed of an object is , then direction will be "calculated" to . This causes a few problems as is right, not "no direction".
  • Changing an object's x/y-position is considered "teleporting" by Game Maker and will not influence or change vspeed.

Related Pages


  • direction - the direction an object is moving, in degrees.
  • speed - an objects speed in relation to direction.
  • hspeed - the horizontal equivalent of vspeed


Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution 2.5 License.