Events Puzzles Reference — Soft8Soft
Description: Handling user events with Verge3D Puzzles.

# Events

The puzzles from this category handle user-generated events: mouse clicks / touches, hovering and dragging.

## Contents

- Puzzles Reference
  - when clicked
  - picked object
  - when hovered
  - hovered object
  - when moved
  - when dragged
  - drag move
  - drag rotate
  - drag scale
  - dragged object

#

## Puzzles Reference

#

### when clicked

Waits until a user clicks on a specified 3D object (or any object in a specified list or group, or any object on the scene if the all objects puzzle is used) — then runs puzzles in the do slot.

If the enable "if missed" action checker enabled in the gear popup, additional if missed: do slot appears. The puzzles in this slot are triggered when the user clicks on some other object or on the background.

The advanced event options checker in the gear popup activates the following properties:

x-ray
  Allow clicking the object behind any unclickable objects. Useful for clicking objects located behind semi-transparent surfaces or objects rendered above all (decalls or x-rayed geometries).
double click / tap
  Execute puzzles in response to double click (desktops) or double tap events (mobiles).
mouse buttons
  Execute puzzles only for the specified mouse buttons: left, middle, or right.

When unique picked object id checker is activated in the gear popup, the puzzle will pass a unique ID into the supplemental picked object puzzle instead of the object's name. This allows you to assign click listeners on models that have the same names (due to being appended dynamically or cloned):

when clicked is one of the most frequently used puzzles, being the easiest method to add interactivity to your scene. For example, you can start playing animation upon clicking on some object (e.g. a push button parented to the camera):

or you can change material then the user clicks e.g. on a palette (swatch) object:

or just play fancy sound to make interactions with your scene more immersive:

#

### picked object

Returns an object a user has clicked on. Intended for use with the when clicked puzzle.

#

### when hovered

Waits until a user hovers over/out a specified 3D object (or any object in a specified list or group, or any object on the scene if the all objects puzzle is used) — then runs puzzles in the over/out: do slot.

This puzzle works only on devices controlled by the mouse cursor, i.e. desktops and laptops. On touch screen devices it will do nothing.

The advanced event options checker in the gear popup activates the following property:

x-ray
  Allow hovering behind other objects. Useful for outlining objects located behind semi-transparent surfaces or objects rendered above all (decalls or x-rayed geometries).

#

### hovered object

Returns an object a user has hovered over. Intended for use with the when hovered puzzle.

This puzzle works only on devices controlled by the mouse cursor, i.e. desktops and laptops. On touch screen devices it will do nothing.

#

### when moved

Tracks any movements (position, rotation and scale) of a specified object (or any object in a specified list or group, or any object on the scene if the all objects puzzle is used). Runs puzzles in the start: do slot if an object started moving, keeps running puzzles in the while moving: do slot until an object stops moving, then runs puzzles in the stop: do slot. The velocity parameter denotes a per-second change of any coordinate (x, y or z) of either of position, rotation or scale that is required to trigger this puzzle.

#

### when dragged

Waits until a user drags over a specified 3D object (or any object in a specified list or group, or any object on the scene if the all objects puzzle is used) with the mouse or a touch gesture — then generates movement data for using in a drag move, drag rotate or drag scale puzzle.

The advanced event options checker in the gear popup activates the following properties:

x-ray
  Allow dragging the object behind other objects. Useful for dragging objects located behind semi-transparent surfaces or objects rendered above all (decalls or x-rayed geometries).
mouse buttons
  Drag only with the specified mouse buttons: left, middle, or right.

The enable start action and enable drop action checkers activate the corresponding slots used to capture the events of started and stopped dragging.

#

### drag move

Moves a specified 3D object (or all objects in a specified list or group, or all objects on the scene if the all objects puzzle is used) in accordance to dragging movement data generated by the when dragged puzzle. Use the mode drop-down menu to limit the movement to a particular axis or plane, or set XYZ to move freely in all directions.

The use "space" option checker in the gear popup activates the space drop-down menu:

world
  Perform movements in world coordinates, e.g. ignore any parent-child relations for the object. This mode is used by default.
parent
  Perform movements relatively to the parent object.
local
  Perform movements relatively to the object itself.

#

### drag rotate

Rotates a specified 3D object (or all objects in a specified list or group, or all objects on the scene if the all objects puzzle is used) in accordance to dragging movement data generated by the when dragged puzzle. Use the mode drop-down menu to limit the rotation to a particular axis.

The use "space" option checker in the gear popup activates the space drop-down menu:

world
  Perform rotations in world coordinates, e.g. ignore any parent-child relations for the object. This mode is used by default.
parent
  Perform rotations relatively to the parent object.
local
  Perform rotations relatively to the object itself.

#

### drag scale

Scales a specified 3D object (or all objects in a specified list or group, or all objects on the scene if the all objects puzzle is used) in accordance to dragging movement data generated by the when dragged puzzle. Use the mode drop-down menu to limit scaling to a particular axis or set XYZ to scale the object uniformly.

#

### dragged object

Returns the object over which the mouse cursor or touch pointer moved when dragging. Intended for use with the drag move, drag rotate, or drag scale puzzles when the dragged over object itself should be moved.

## Having Troubles with Puzzles?

Seek help on the forums!