Home | Customize | Blog | Extras | Log In | Info
Manual | D&D icons | GML Parser | Archive | Iso City
Username: Password:  
About | Features | Directory | Banners | Contact

Designing Games with GameMaker
Designing Games with GameMaker

Move actions

The first set of actions consists of those related to movement of objects. The following actions exist:

Move Fixed
Use this action to start the instance moving in a particular direction. You can indicate the direction using the buttons with the arrows on it. Use the middle button to stop the motion. Also you need to specify the speed of the motion. This speed is given in pixels per step. Preferably don't use negative speeds. You can specify multiple directions. In this case a random choice is made. In this way you can let a monster start moving either left or right.

Move Free
This is the second way to specify a motion. Here you can indicate a precise direction. This is an angle between 0 and 360 degrees. 0 means to the right. The direction is counter-clockwise. So for example 90 indicates an upward direction. If you want an arbitrary direction, you can type random(360). As you will see below the function random gives a random number smaller than the indicated value. As you might have noticed there is a checkbox labeled Relative. If you check this, the new motion is added to the previous one. For example, if the instance is moving upwards and you add some motion to the left, the new motion will be upwards to the left.

Move Towards
This action gives a third way to specify a motion. You indicate a position and a speed and the instance starts moving with the speed towards the position. (It won't stop at the position!) For example, if you want a bullet to fly towards the position of the spaceship you can use as position spaceship.x, spaceship.y. (You will learn more about the use of variables like these below.) If you check the Relative box, you specify the position relative to the current position of the instance. (The speed is not taken relatively!)

Speed Horizontal
The speed of an instance consists of a horizontal part and a vertical part. With this action you can change the horizontal speed. A positive horizontal speed means a motion to the right. A negative one means a motion to the left. The vertical speed will remain the same. Use relative to increase the horizontal speed (or decrease it by providing a negative number).

Speed Vertical
In a similar way, with this action you can change the vertical speed of the instance.

Set Gravity
With this action you can create gravity for this particular object. You specify a direction (angle between 0 and 360 degrees) and a speed, and in each step this amount of speed in the given direction is added to the current motion of the object instance. Normally you need a very small speed increment (like 0.01). Typically you want a downward direction (270 degrees). If you check the Relative box you increase the gravity speed and direction. Note that, contrary to real life, different object can have different gravity directions.

Reverse Horizontal
With this action you reverse the horizontal motion of the instance. This can for example be used when the object collides with a vertical wall.

Reverse Vertical
With this action you reverse the vertical motion of the instance. This can for example be used when the object collides with a horizontal wall.

Set Friction
Friction slows down the instances when they move. You specify the amount of friction. In each step this amount is subtracted from the speed until the speed becomes 0. Normally you want a very small number here (like 0.01).

Jump to Position
Using this action you can place the instance in a particular position. You simply specify the x- and y-coordinate, and the instance is placed with its reference point on that position. If you check the Relative box, the position is relative to the current position of the instance. This action is often used to continuously move an instance. In each step we increment the position a bit.

Jump to Start
This action places the instance back at the position where it was created.

Jump to Random
This action moves the instance to a random position in the room. Only positions are chosen where the instance does not intersect any solid instance. You can specify the snapping used. If you specify positive values, the coordinates chosen with be integer multiples of the indicated values. This could for example be used to keep the instance aligned with the cells in your game (if any). You can specify a separate horizontal snapping and vertical snapping.

Align to Grid
With this action you can round the position of the instance to a grid. You can indicate both the horizontal and vertical snapping value (that is, the size of the cells of the grid). This can be very useful to make sure that instances stay on a grid.

Wrap Screen
With this action you can let an instance wrap around, that is, when it leaves on one side of the room it reappears at the other side. This action is normally used in the Outside event. Note that the instance must have a speed for wrapping to work, cause the direction of wrapping is based on the direction of the motion. You can indicate whether to wrap only horizontal, only vertical, or in both directions.

Move to Contact
With this action you can move the instance in a given direction until a contact position with an object is reached. If there already is a collision at the current position the instance is not moved. Otherwise, the instance is placed just before a collision occurs. You can specify the direction but also a maximal distance to move. For example, when the instance is falling you can move a maximal distance down until an object is encountered. You can also indicate whether to consider solid object only or all objects. You typically put this action in the collision event to make sure that the instance stops in contact with the other instance involved in the collision.

Bounce
When you put this action in the collision event with some object, the instance bounces back from this object in a natural way. If you set the parameter precise to false, only horizontal and vertical walls are treated correctly. When you set precise to true also slanted (and even curved) walls are treated correctly. This is though slower. Also you can indicate whether to bounce only against solid objects or against all objects. Please realize that the bounce is not completely accurate because this depends on many properties. But in many situations the effect is good enough.

Search Search


Alternative versions Alternative versions

You can also read this manual on one single long page (± 1.5 mb)

Also available in: Dutch French German

ZIP Download helpfile

Advertisement Advertisement

GameMaker Manual