Skip to main content

createProximityAction

Creates a proximity action attached to the object.

Syntax

object.createProximityAction(options, withId);

Parameters

NameTypeDescription
options (optional)ProximityActionOptionsThe options to create the proximity action.
withId (optional)stringThe id of the proximity action.

Returns

Example

// create a proximity action
const proximityAction = object.createProximityAction(
{
position: [3, 2, 3],
label: 'Nice music',
description: 'Play a sound',
key: 'KeyF',
distance: 3,
},
'my-custom-id',
);

// listen to the proximity action trigger
proximityAction.on(event => {
console.log('Proximity action triggered', event);
});

Available on: Client