Skip to main content

Cursor

How the Interaction Kit cursor and ray show what each interactor targets on SPECS, and how to choose, change, or hide them for an Interactable or from a script.

  • Snapchat: not supported
  • SPECS: fully supported
  • Camera Kit Web: not supported
  • Camera Kit Mobile: not supported
  • SnapchatNot supported
  • SPECSFully supported
  • Camera Kit WebNot supported
  • Camera Kit MobileNot supported

Platform details

  • Snapchat — Not supported.

  • SPECS — Fully supported.

  • Camera Kit Web — Not supported.

  • Camera Kit Mobile — Not supported.

Interaction Kit shows the user what they are targeting with a cursor and a ray. When users interact from farther away than arm's reach (the "far-field" case), the InteractorCursor follows the direction of the user's interactor to the object it targets, which helps users aim at distant objects, and it changes automatically to give feedback while it targets an object.

How CursorController gives each interactor a cursor and a ray

To give every interactor cursor feedback, Interaction Kit provides the CursorController component. When the Lens starts, CursorController creates an InteractorCursor and an InteractorRayVisual for each interactor in the scene. CursorController is part of the InteractionKit prefab, on [OPTIONAL] Visuals > InteractorCursors.

  • InteractorCursor reads the state of its interactor (position, direction, and target) to place the cursor and adjust its visual feedback to that state.
  • InteractorRayVisual draws a ray from the interactor to the cursor. The cursor's state drives the ray's length and opacity.

On SPECS, the system presents the cursors of the hand interactors. In the Lens Studio Preview panel, and for interactors other than hands, Interaction Kit renders the cursor itself.

To see how the cursor finds its target, turn on Draw Debug on CursorController: it draws each cursor's cone collider, its center ray, and the closest-point helpers.

Choose a cursor or a ray for an Interactable

Each Interactable sets what shows while an interactor targets it, with Targeting Visual: Cursor (the default), Ray, or None. An InteractionPlane around the Interactable overrides that choice for every Interactable under it, unless the Interactable turns on Ignore Interaction Plane. See Interaction System.

InteractorLineVisual, which drew a line for an interactor in earlier versions, is deprecated and no longer recommended for new projects; InteractorRayVisual replaces it.

Get and change cursors from a script

IK.CursorController returns the CursorControllerProvider, which finds the cursors that CursorController created:

MethodReturns
getAllCursors()Every InteractorCursor in the scene.
getCursorByInteractor(interactor)The InteractorCursor of an interactor, or null. Replaces the deprecated getCursor.
getCursorByInputType(inputType)The InteractorCursor of an InteractorInputType, or null.

Disabling an InteractorCursor (cursor.enabled = false) hides it and its ray. To change its look, set cursorMode to a CursorMode (InteractionKit.lspkg/Components/Interaction/InteractorCursor/InteractorCursor): Auto (the default), Disabled, or Custom show the pointer cursor, and Translate, ScaleTopLeft, and ScaleTopRight show manipulation cursors. Before setting Custom, set the cursor's customTexture.

This script hides every cursor in the scene:

import { IK } from 'InteractionKit.lspkg/IK';

@component
export class ExampleCursorScript extends BaseScriptComponent {
onAwake() {
this.createEvent('OnStartEvent').bind(() => {
this.onStart();
});
}

onStart() {
const cursorController = IK.CursorController;

// Hide every cursor in the scene, and its ray.
const cursors = cursorController.getAllCursors();
for (const cursor of cursors) {
cursor.enabled = false;
}
}
}