BLOCK REFERENCE / SENSING

Sensing

Questions about the world: touching another object? where is the mouse? how much time passed?

16 blocks

Delta Time

Reporter→ numbersensing_delta_time
Delta Time

Returns the time in seconds since the previous frame.

Usually about 0.016 at 60 FPS, and never more than 0.1. It is 0 in When Game Starts.

Example Multiply a speed in pixels/second by Delta Time so movement is the same on fast and slow computers.

Dialogue or menu is open

Boolean→ booleangame.modal_open
Dialogue or menu is open

True while a dialogue box or choice menu is waiting for the player.

Walk on grid (arrows / WASD) and Platformer controls already pause by themselves; use this block to pause your own controls too.

Distance To Object

Reporter→ numbersensing_distance_to_object
Distance To Object

Returns the distance in pixels from this object to another object.

Measured in a straight line between the top-left corners of both objects, not their centers. Returns 0 if the object is not found.

FieldWhat it means
ObjecttextName of the other object (not case sensitive). If several share the name, the first one found is used.Default: Enemy

Finished a grid step

Boolean→ booleangame.grid_arrived
Finished a grid step

True on the frame this object finishes a step of Walk on grid (arrows / WASD).

It is true for exactly one frame per completed cell, so it is a good moment to check tiles, doors or random encounters.

Is faced by

Boolean→ booleangame.faced_by
Is faced by

True when the named grid-walking object stands next to this one and faces it.

The other object must be standing still, and the cell right in front of it must overlap this object.

FieldWhat it means
objecttextName of the object that uses Walk on grid (arrows / WASD), usually Player (not case sensitive).Default: Player

Example On an NPC: Is faced by Player And Key just pressed z opens a dialogue.

Key just pressed

Boolean→ booleangame.key_just_pressed
Key just pressed

True only on the frame one of the listed keys goes down.

Holding the key does not repeat it; it becomes true again only after the key is released and pressed again.

FieldWhat it means
keys (space separated)textKey names separated by spaces or commas, for example z enter. Supported: space, enter, escape, arrow keys (up, down, left, right) and the letters w a s d q e r f z x c v.Default: z enter

Example Use it in On Update to fire one bullet per press.

Key Pressed?

Boolean→ booleansensing_key_pressed
Key Pressed?

True while a key is held down.

It stays true every frame the key is held. Use Key just pressed to react only once per press.

FieldWhat it means
KeydropdownKey to check: space, enter, escape, the arrow keys (up, down, left, right) or w, a, s, d.Options: space · enter · escape · up · down · left · right · w · a · s · d

Lands on me

Boolean→ booleangame.landed_on_by
Lands on me

True when the named object touches this one while landing on its top, as in a stomp.

It counts when the other object is not moving upward and its bottom edge is within the upper part of this object's collider. This object needs a collider.

FieldWhat it means
objecttextName of the object that lands (not case sensitive), for example Player.Default: Player

Example On an enemy: if Lands on me Player, Launch upward Player and destroy the enemy.

Mouse Down?

Boolean→ booleansensing_mouse_down
Mouse Down?

True while a mouse button is held down.

FieldWhat it means
ButtondropdownButton to check: left, right or middle.Options: left · right · middle

Mouse X

Reporter→ numbersensing_mouse_x
Mouse X

Returns the mouse pointer's horizontal position in world pixels.

Uses world coordinates, taking the camera position and zoom into account, so it can be compared directly with object positions.

Mouse Y

Reporter→ numbersensing_mouse_y
Mouse Y

Returns the mouse pointer's vertical position in world pixels.

Uses world coordinates with the camera applied. Y grows downward: bigger values are lower on screen.

Object Rotation

Reporter→ numbersensing_object_rotation
Object Rotation

Returns this object's rotation in degrees.

Object X

Reporter→ numbersensing_object_x
Object X

Returns this object's X position in pixels.

This is the left edge of the object in world coordinates.

Object Y

Reporter→ numbersensing_object_y
Object Y

Returns this object's Y position in pixels.

This is the top edge of the object in world coordinates. Y grows downward.

Timer

Reporter→ numbersensing_timer
Timer

Returns the seconds elapsed since the scene started playing.

It starts at 0 each time a scene starts or the game restarts.

Touching Object?

Boolean→ booleansensing_touching_object
Touching Object?

True when this object is touching any object with the given name.

Both objects need a collider enabled. Trigger colliders count too. Inactive objects are never touching.

FieldWhat it means
ObjecttextName to look for (not case sensitive). Every object with that name counts, so it works with many Enemy or Wall copies.Default: Enemy