Voxel Playground Mod Documentation - v0.4.0
    Preparing search index...

    Modify Voxels

    For current mods, prefer the voxel operations exposed through ModAPI rather than direct unsafe voxel memory access. The generated typings already expose the most common runtime operations you need from TypeScript.

    The practical order of preference is:

    1. Use ModAPI helpers on VoxelDestructor or VoxelVolume.
    2. Listen for voxel change events through ModAPI.
    3. Avoid low-level direct data mutation from TypeScript unless the toolkit exposes a safe wrapper for the exact operation you need.

    The generated typings expose common helpers such as:

    • DemolishVoxelSphere
    • ClearVoxelScreenLine
    • ClearVoxelBoxSweep
    • ClearVoxelCylinder
    • ExplodeVoxelObject
    • ModifyVoxelProperty
    • ProjectVoxelDecal

    These are the preferred tools for gameplay features such as explosions, sword slashes, drilling, painting, or decals.

    const ModAPI = VX.Mod.ModAPI;

    ModAPI.DemolishVoxelSphere(
    voxelDestructor,
    impactPosition,
    4.0,
    25.0,
    bindTo.transform.forward
    );

    The katana sample uses this pattern to cut voxel chunks:

    ModAPI.ClearVoxelScreenLine(
    voxelDestructor,
    screenA,
    screenB,
    worldToScreen,
    chunk
    );

    When you only need to inspect voxel data, use the read helpers:

    • GetVoxelSolidCount
    • GetVoxelOriginalSolidCount
    • GetVoxelSolidRatio
    • GetVoxelAtWorld
    • GetVoxelAtLocal
    • GetVoxelAtHit
    const ModAPI = VX.Mod.ModAPI;

    const initialCount = ModAPI.GetVoxelOriginalSolidCount(voxelVolume);

    const onVoxelModified = () => {
    const ratio = ModAPI.GetVoxelSolidCount(voxelVolume) / initialCount;
    if (ratio < 0.95) {
    ModAPI.PlayVFX("NuclearBomb_Explode", bindTo.transform.position, 2.0);
    }
    };

    ModAPI.AddVoxelModifiedListener(voxelVolume, onVoxelModified);

    This is the same family of pattern used by the Homelander sample.

    If you want a voxel object to burst apart rather than just lose a region, use:

    VX.Mod.ModAPI.ExplodeVoxelObject(voxelDestructor, true, true);
    

    Use this for scripted destruction set pieces, death reactions, or failure states.