Interactive Objects

advanced scripting

Voxel Play 3 · Scripting / API

Overview

Voxel Play offers a base class enabling developers to create interactive objects that respond when players approach, leave, or trigger actions (typically pressing key E).

A door serves as an example. The sample world includes door voxels with a Door script demonstrating this functionality:

public class Door : VoxelPlayInteractiveObject {
    ...
}

Fields

  • string customTag - User-defined tag for distinguishing objects (e.g. differentiating left/right doors)
  • float interactionDistance = 4f - Maximum distance for player interaction
  • bool triggerNearbyObjects - Activates nearby objects when triggered (useful for double doors)
  • bool playerIsNear - Boolean indicating player proximity (set by Voxel Play)
  • VoxelChunk chunk - Chunk containing this object
  • int voxelIndex - Index of the voxel in the chunk

Virtual Methods

  • virtual void OnStart() - Called during initialization. The env field provides access to the Voxel Play Environment API.
  • virtual void OnPlayerApproach() - Called when player enters interaction range
  • virtual void OnPlayerGoesAway() - Called when player leaves interaction range
  • virtual void OnPlayerAction() - Called when player interacts (presses E)
Was this page helpful?