# 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.

<figure><img src="/files/O1E5vlsLRfvmjhROSvYT" alt="" width="254"><figcaption></figcaption></figure>

## 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`.

```typescript
@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.

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

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hology.app/visual-effects/vfx-assets.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
