Interactive Objects
advanced scriptingVoxel 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 interactionbool 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 objectint voxelIndex- Index of the voxel in the chunk
Virtual Methods
virtual void OnStart()- Called during initialization. Theenvfield provides access to the Voxel Play Environment API.virtual void OnPlayerApproach()- Called when player enters interaction rangevirtual void OnPlayerGoesAway()- Called when player leaves interaction rangevirtual void OnPlayerAction()- Called when player interacts (presses E)
Was this page helpful?
Suggest an improvement
Help us improve this documentation page.