VFX Assets

Creating a VFX Asset

You can create a new visual effect by clicking "Add new" in the asset browser. You will be prompted to enter a name for the visual effect asset.

Placing visual effect in a scene

After creating a visual effect, you can place them in scenes and prefabs just like other 3D models. In the asset browser, filter on "Visual Effects". Then click and drag the visual effect into the scene to place it.

Using VFX assets in code

Spawning a VFX actor from asset ID

You can reference a VFX asset in your code using the asset ID. This will spawn a VFX actor in the world and return it to you so that you can control the vfx using methods like play, stop, or adjust timescale.

@Actor()
class Player {
    private vfx = inject(VfxService)

    async onInit() {
        const vfxActor = await this.vfx.createFromAssetId('your-asset-id')
        vfxActor.play()
    }
}

Spawning a VFX actor using a Visual Effect parameter

To enable configuring which visual effect to use in the Hology editor, you can define a parameter on the actor. This can enable you to alse reuse the same actor class but change the visual effect asset.

@Actor()
class Player {
    @Parameter()
    private vfxParam: VisualEffect 

    async onInit() {
        const vfxActor = await this.vfxParam.create()
        vfxActor.play()
    }
}

Last updated