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

    Tutorial: Homelander

    This tutorial covers the current Homelander sample in Assets/Samples/com.cydream.homelander. The sample combines imported voxel content, scene rendering settings, and TypeScript-driven behavior.

    The sample ships with:

    • Imported voxel data in Data/
    • A ready-to-export prefab in Prefab/
    • A mod-local rendering settings asset
    • TypeScript scripts in Scripts/

    Use this as the reference layout if you are building a character or scene showcase with custom scripted reactions.

    The sample uses two TypeScript classes:

    • Homelander
    • LaserAim

    Both are exported from Scripts/index.ts and are meant to run through JsComponentProxy on the appropriate prefab objects.

    This script watches voxel damage on the owning VoxelVolume. When the remaining solid voxel count drops below the configured threshold, it:

    • Plays explosion audio / VFX.
    • Releases attached rigidbodies from kinematic mode.
    • Removes unyielding protection from linked destructors.

    This script spawns a builtin laser gun entity, pins it in place, and steers it toward the currently controlled character or vehicle through ModAPI.

    To reproduce the sample behavior:

    1. Add JsComponentProxy to the object that owns the destructible voxel volume and point it at Homelander.
    2. Add another JsComponentProxy where the laser aiming behavior should live and point it at LaserAim.
    3. Make sure the relevant object has the required engine-side components such as VoxelVolume.
    4. Include the prefab in manifest.asset.

    This sample is a useful reference for two TypeScript patterns:

    • Listening to engine-side events through ModAPI, such as voxel modification callbacks.
    • Spawning and driving builtin game content from TypeScript instead of writing glue MonoBehaviours.

    Minimal structure:

    export class Homelander {
    constructor(bindTo: VX.Mod.JsComponentProxy) {
    bindTo.onStart = () => this.onStart();
    bindTo.onDestroy = () => this.onDestroy();
    }
    }

    Before exporting:

    npm run lint:mod -- com.cydream.homelander
    

    Then verify:

    • Laser aiming activates when a valid target is present.
    • Damage to the voxel body triggers the scripted explosion threshold.
    • The prefab and rendering settings are included in the exported mod.