BLOCK REFERENCE / MOTION

Motion

Position, rotation, size and movement of objects.

31 blocks

Face direction

Actiongame.face_direction
Face direction

Turns this object to face up, down, left or right and plays the matching Idle animation.

Plays IdleUp, IdleDown, IdleLeft or IdleRight if the object has it (IdleLeft falls back to a mirrored IdleRight, then to Idle). The facing is shared with Walk on grid; rotation does not change. Any other value stops the game with an error.

FieldWhat it means
direction {…}textup, down, left or right. Accepts {templates}, e.g. {facing}.Default: down

Face toward object

Actiongame.face_toward
Face toward object

Turns this object to face another object (up, down, left or right) and plays that Idle animation.

Compares the centres of both objects and picks the axis with the larger distance. Rotation does not change. Does nothing if the object is not found.

FieldWhat it means
objecttextName of the object to look at (not case-sensitive).Default: Player

Example An NPC turns to the player before starting a dialogue.

Go to random free cell

Actiongame.random_free_cell
Go to random free cell

Moves this object to a random grid cell that is not covered by any collider.

The grid starts at left, top and has columns by rows square cells. A cell is free when its centre is outside every other active collider, triggers included. The object is centred in the chosen cell; if none is free, nothing happens.

FieldWhat it means
cellnumberCell size in pixels (1 to 1000).Default: 30
leftnumberX of the grid's left edge, in pixels.Default: 0
topnumberY of the grid's top edge, in pixels (y grows downward).Default: 0
columnsnumberNumber of columns (1 to 500).Default: 10
rowsnumberNumber of rows (1 to 500).Default: 10

Example Move the snake's food to a free spot after it is eaten.

Go to x y {…}

Actiongame.go_to
Go to x y {…}

Moves this object to an x, y position given as numbers or {templates}.

Both values must turn into numbers, otherwise the game stops with an error. The position is the object's top-left corner in world pixels, with y growing downward.

FieldWhat it means
xtextX in pixels: a number or a template like {global.x} or {Player.x}.Default: {global.x}
ytextY in pixels: a number or a template like {global.y}.Default: {global.y}

Example Save the player's spot in globals before changing scene, then use this block to come back to it.

Grow trail

Actiongame.trail_grow
Grow trail

Adds copies of an object to the end of this object's grid trail, like a snake that grows.

Works with Move on grid, which places each segment on the path left behind. New segments stay hidden and without collision until the path is long enough. Copies keep the original's name; up to 2000 segments.

FieldWhat it means
clone oftextObject to copy for each segment (label clone of); it cannot be this object.Default: Body
countnumberSegments to add (1 to 50).Default: 1

Example When the snake eats food, grow the trail by 1.

Keep inside area

Actiongame.clamp_position
Keep inside area

Keeps this object's position inside a rectangle.

Limits x and y (the top-left corner, or the centre of the view on a Camera) to the given range. Use it every frame in On Update. If a minimum is greater than its maximum, the game stops with an error.

FieldWhat it means
min xnumberSmallest allowed x, in pixels.Default: 0
max xnumberLargest allowed x, in pixels.Default: 1000
min ynumberSmallest allowed y, in pixels (y grows downward).Default: 0
max ynumberLargest allowed y, in pixels.Default: 1000

Example On the Camera, after Follow object smoothly, so the view never goes past the level edges.

Lerp To Position

Actionmotion_lerp_to_position
Lerp To Position

Moves this object part of the way toward a target position, easing in as it gets closer.

Each run covers speed times the frame time of the remaining distance (all of it once that reaches 1), so use it in On Update. With a frame time of 0, as in When Game Starts, nothing happens.

FieldWhat it means
XnumberTarget x in pixels.Default: 0
YnumberTarget y in pixels.Default: 0
SpeednumberHow fast it closes the gap; 5 covers about 90% of the distance in half a second. Negative values count as 0.Default: 5
XsocketTarget x in pixels.Default: number, any
YsocketTarget y in pixels.Default: number, any
SpeedsocketHow fast it closes the gap; 5 covers about 90% of the distance in half a second. Negative values count as 0.Default: number, any

Look At Mouse

Actionmotion_look_at_mouse
Look At Mouse

Rotates this object so its facing direction points at the mouse pointer.

Measures from the object's x, y (its top-left corner) to the pointer in world coordinates. Rotation 0 faces right and 90 faces down. Use it in On Update to keep aiming.

Example A turret that always aims at the pointer.

Move

Actionmotion_move
Move

Moves this object by an amount in the mode you pick: forward, backward, left, right, along x or y, or at an angle.

forward and backward follow the object's rotation (0 = right, 90 = down); angle uses the angle value instead. left and right move along x, and x and y add the amount to that axis (y grows downward). Moves once per run, not scaled by frame time.

FieldWhat it means
Modedropdownforward, backward, left, right, x, y or angle.Options: forward · backward · left · right · x · y · angle
AmountnumberDistance in pixels. Negative values move the other way.Default: 10
AnglenumberDirection in degrees for the angle mode (0 = right, 90 = down). Only shown in that mode.Default: 0
AmountsocketDistance in pixels. Negative values move the other way.Default: number, any
AnglesocketDirection in degrees for the angle mode (0 = right, 90 = down). Only shown in that mode.Default: number, any

Move Backward

Actionmotion_move_backward
Move Backward

Moves this object backward, opposite to the direction it faces, by a number of pixels.

Uses the current rotation: with rotation 0 it moves left.

FieldWhat it means
AmountnumberDistance in pixels. Negative values move forward.Default: 10
AmountsocketDistance in pixels. Negative values move forward.Default: number, any

Move By Angle

Actionmotion_move_by_angle
Move By Angle

Moves this object a number of pixels in a given direction, without changing its rotation.

FieldWhat it means
AnglenumberDirection in degrees: 0 = right, 90 = down, 180 = left, 270 (or -90) = up.Default: 45
AmountnumberDistance in pixels. Negative values move the opposite way.Default: 10
AnglesocketDirection in degrees: 0 = right, 90 = down, 180 = left, 270 (or -90) = up.Default: number, any
AmountsocketDistance in pixels. Negative values move the opposite way.Default: number, any

Example Knock the player back at the angle it was hit from.

Move Forward

Actionmotion_move_forward
Move Forward

Moves this object forward, in the direction it faces, by a number of pixels.

Uses the current rotation: 0 faces right and 90 faces down. Inside On Update it moves that far every frame.

FieldWhat it means
AmountnumberDistance in pixels. Negative values move backward.Default: 10
AmountsocketDistance in pixels. Negative values move backward.Default: number, any

Example Combine with Rotate By for car-style steering.

Move Left

Actionmotion_move_left
Move Left

Moves this object left by a number of pixels.

Subtracts the amount from x and ignores rotation.

FieldWhat it means
AmountnumberDistance in pixels. Negative values move right.Default: 10
AmountsocketDistance in pixels. Negative values move right.Default: number, any

Move on grid

Actiongame.grid_step
Move on grid

Moves this object one grid cell in its steered direction at a steady interval, snake-style.

Use it in On Update with Steer on grid for turns; it starts heading right. The interval shrinks by faster_per_segment per trail segment, down to min_interval. Segments added with Grow trail follow the path.

FieldWhat it means
cellnumberStep size in pixels (1 to 1000).Default: 30
seconds per stepnumberSeconds between steps (label seconds per step).Default: 0.15
faster per segmentnumberSeconds taken off the interval for each trail segment (label faster per segment).Default: 0.004
fastestnumberShortest allowed interval in seconds (label fastest).Default: 0.06
rotatedropdownon turns the object to face where it moves; off keeps its rotation.Options: on · off

Move Right

Actionmotion_move_right
Move Right

Moves this object right by a number of pixels.

Adds the amount to x and ignores rotation.

FieldWhat it means
AmountnumberDistance in pixels. Negative values move left.Default: 10
AmountsocketDistance in pixels. Negative values move left.Default: number, any

Move X By

Actionmotion_move_x_by
Move X By

Changes this object's x position by a number of pixels.

Positive values move right, negative values move left. Ignores rotation.

FieldWhat it means
AmountnumberPixels to add to x.Default: 10
AmountsocketPixels to add to x.Default: number, any

Example Plug Get Axis Horizontal times 5 into it inside On Update for simple left and right movement.

Move Y By

Actionmotion_move_y_by
Move Y By

Changes this object's y position by a number of pixels.

y grows downward: positive values move down and negative values move up. Ignores rotation.

FieldWhat it means
AmountnumberPixels to add to y.Default: 10
AmountsocketPixels to add to y.Default: number, any

Orbit Around Object

Actionmotion_orbit_around_object
Orbit Around Object

Places this object on a circle around another object, driven by the game clock.

The angle comes from the time since play started, so with speed 1 it makes a full turn every 2 seconds, clockwise on screen. It sets the position from the other object's x, y (top-left corner), so run it every frame in On Update. Does nothing if the object is not found.

FieldWhat it means
ObjecttextName of the object to circle around.Default: Center
RadiusnumberDistance from that object, in pixels.Default: 100
SpeednumberHalf-turns per second; negative values orbit the other way.Default: 1
RadiussocketDistance from that object, in pixels.Default: number, any
SpeedsocketHalf-turns per second; negative values orbit the other way.Default: number, any

Patrol back and forth

Actiongame.patrol
Patrol back and forth

Moves this object back and forth from its starting position forever, for enemies and moving platforms.

Use it in On Update. The start is where the object was the first time the block ran. With face_direction on, the object is mirrored while it heads toward smaller x, so draw the sprite facing right.

FieldWhat it means
axisdropdownx for left and right, y for up and down.Options: x · y
distancenumberHow far to go, in pixels; negative values go the other way first.Default: 200
speednumberAverage speed in pixels per second.Default: 80
styledropdownsmooth eases in and out at each end; linear keeps a constant speed.Options: smooth · linear
face directiondropdownon mirrors the sprite to face the way it moves (x axis only).Options: on · off

Point To Angle

Actionmotion_point_to_angle
Point To Angle

Sets this object's rotation to an angle in degrees.

0 faces right, 90 down, 180 left and 270 up; bigger angles turn clockwise. Same result as Set Rotation.

FieldWhat it means
AnglenumberAngle in degrees.Default: 0
AnglesocketAngle in degrees.Default: number, any

Point To Object

Actionmotion_point_to_object
Point To Object

Rotates this object so it faces another object.

Aims from this object's x, y to the other object's x, y (their top-left corners), so objects of different sizes can end up slightly off-centre. Does nothing if the object is not found.

FieldWhat it means
ObjecttextName of the object to face (not case-sensitive).Default: Player

Rotate By

Actionmotion_rotate_by
Rotate By

Turns this object by a number of degrees.

Positive values turn clockwise on screen, negative values counter-clockwise. Inside On Update it turns that much every frame.

FieldWhat it means
AmountnumberDegrees to turn.Default: 15
AmountsocketDegrees to turn.Default: number, any

Example A small value in On Update makes a spinning coin.

Set Height

Actionmotion_set_height
Set Height

Sets this object's height in pixels.

Values below 1 become 1. The collider keeps its own size.

FieldWhat it means
HeightnumberNew height in pixels.Default: 100
HeightsocketNew height in pixels.Default: number, any

Set Position

Actionmotion_set_position
Set Position

Moves this object to an exact x, y position.

Coordinates are world pixels for the object's top-left corner; y grows downward.

FieldWhat it means
XnumberNew x in pixels.Default: 0
YnumberNew y in pixels.Default: 0
XsocketNew x in pixels.Default: number, any
YsocketNew y in pixels.Default: number, any

Example Send the player back to the start of the level after falling.

Set Rotation

Actionmotion_set_rotation
Set Rotation

Sets this object's rotation to an angle in degrees.

0 faces right and 90 faces down. The sprite turns around its centre; the collider does not rotate.

FieldWhat it means
AnglenumberAngle in degrees.Default: 0
AnglesocketAngle in degrees.Default: number, any

Set Scale

Actionmotion_set_scale
Set Scale

Multiplies this object's current width and height by the given factors.

Despite its name it is relative: running it twice with 2 makes the object four times as wide. Use Set Width and Set Height for exact sizes. Sizes never go below 1 pixel, and the collider keeps its own size.

FieldWhat it means
Scale XnumberWidth multiplier (1 = unchanged, 2 = double, 0.5 = half).Default: 1
Scale YnumberHeight multiplier (1 = unchanged, 2 = double, 0.5 = half).Default: 1
Scale XsocketWidth multiplier (1 = unchanged, 2 = double, 0.5 = half).Default: number, any
Scale YsocketHeight multiplier (1 = unchanged, 2 = double, 0.5 = half).Default: number, any

Set Width

Actionmotion_set_width
Set Width

Sets this object's width in pixels.

Values below 1 become 1. The collider keeps its own size.

FieldWhat it means
WidthnumberNew width in pixels.Default: 100
WidthsocketNew width in pixels.Default: number, any

Set X

Actionmotion_set_x
Set X

Sets this object's x position.

x is the object's left edge in world pixels; it grows to the right.

FieldWhat it means
XnumberNew x in pixels.Default: 0
XsocketNew x in pixels.Default: number, any

Set Y

Actionmotion_set_y
Set Y

Sets this object's y position.

y is the object's top edge in world pixels; it grows downward.

FieldWhat it means
YnumberNew y in pixels.Default: 0
YsocketNew y in pixels.Default: number, any

Steer on grid (arrows / WASD)

Actiongame.grid_steer
Steer on grid (arrows / WASD)

Queues a turn when an arrow key or W, A, S, D is pressed, for objects moved by Move on grid.

Use it every frame in On Update, before Move on grid. It remembers up to two turns so quick presses are not lost, and ignores turning straight back.

Walk on grid (arrows / WASD)

Actiongame.grid_walk
Walk on grid (arrows / WASD)

Walks this object one grid cell at a time with the arrow keys or W, A, S, D, blocked by solid colliders.

Use it in On Update. A quick tap while standing only turns around. Plays WalkUp/WalkDown/WalkLeft/WalkRight and Idle... clips (or Walk/Idle) when present, and pauses while a dialogue box or choice menu is open.

FieldWhat it means
cellnumberCell size in pixels (2 to 1000).Default: 48
cells / secnumberCells per second (0.25 to 60).Default: 4
facing intotextVariable of this object that receives the facing (up, down, left or right); leave it empty to skip.Default: facing
bump sounddropdownSound played when walking into a wall; optional.

Example The player in a top-down RPG.