Programming Guide
advanced scriptingVoxel Play 3 · Scripting / API
Getting Started
Voxel Play 3 exposes its public API through the VoxelPlayEnvironment class (singleton). All methods and properties documented in this section belong to VoxelPlayEnvironment unless otherwise noted.
using VoxelPlay;
// Get the singleton instance
VoxelPlayEnvironment env = VoxelPlayEnvironment.instance;
// Place a voxel
VoxelDefinition stone = env.GetVoxelDefinition("Stone");
env.VoxelPlace(new Vector3d(0, 10, 0), stone);
// Subscribe to events
env.OnVoxelDestroyed += (chunk, voxelIndex) => {
Debug.Log("Voxel destroyed!");
};
Namespace
All Voxel Play types live under the VoxelPlay namespace. Add using VoxelPlay; at the top of your scripts.
Key Types
class VoxelPlayEnvironmentMain API singleton. Access via VoxelPlayEnvironment.instance. All world, voxel, terrain, item, model, and event APIs are accessed through this class.
struct Vector3dDouble-precision 3D vector used for world positions. Supports large worlds without floating-point precision issues.
struct VoxelRepresents a single voxel with its type, color, light, and metadata.
struct VoxelIndexReferences a specific voxel within a chunk (contains chunk reference + voxel array index).
struct VoxelHitInfoContains raycast hit data: chunk, voxel index, hit point, normal, and distance.
class VoxelChunkRepresents a 16×16×16 chunk of voxels. Contains voxel data, mesh, lighting, and colliders.
class VoxelDefinitionScriptable object defining a voxel type (textures, sounds, resistance, rendering mode, etc.).
class ModelDefinitionScriptable object representing a 3D voxel model that can be placed in the world.
class ItemDefinitionScriptable object defining an item (tool, weapon, block) with its properties and category.
class BiomeDefinitionScriptable object defining a biome with its terrain rules, vegetation, and voxel types.
class VoxelPlaceholderMonoBehavior attached to custom voxel GameObjects. Allows per-voxel scripting.
Enums
enum ChunkModifiedFilter { Anyone, OnlyModified, NonModified }Filter for chunk queries. OnlyModified returns chunks changed by the player; NonModified returns untouched chunks.
enum ColliderTypesFilter for collider detection in raycasts and voxel queries.
enum HideStyleControls how hidden voxels are rendered (fully invisible, semi-transparent, etc.).
enum ItemCategoryCategorizes items (voxel, tool, torch, weapon, general).
Delegates
delegate float SDF(Vector3d position)Signed Distance Function delegate used for custom volume definitions when querying voxels in arbitrary shapes.
API Sub-Pages
Due to the extensive API (~177 public methods), the documentation is organized into functional areas:
- World & Chunk Management — World operations, chunk access, visibility, and redraw
- Voxel Operations — Placement, destruction, damage, and collapse
- Voxel Queries — Index lookups, position calculations, and spatial queries
- Voxel Properties — Color, rotation, visibility, custom properties, highlighting, and physics
- Environment & Terrain — Raycasting, terrain height, biomes, water, lighting, and time
- Items & Models — Item spawning, torches, model placement, and UI messaging
- Events — All event callbacks for voxels, chunks, environment, and models
Suggest an improvement
Help us improve this documentation page.