> For the complete documentation index, see [llms.txt](https://stoneforgeteam.gitbook.io/stoneforgeteam-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stoneforgeteam.gitbook.io/stoneforgeteam-docs/content/fx.md).

# Visual effects

`Fx.Play` plays an animation on a unit, following it, as the game's own effect animations do. Use one of the game's sprites, or a strip of your own:

```csharp
// The game's electric weapon hit, at chest height, glowing blue.
Fx.Play(attack.Target, Sprite.s_weapondamage_electricity, new FxOptions
{
    OffsetY = -14,
    Light = Draw.Rgb(110, 170, 255),
});

// A mod's own: a PNG in Assets, its frames side by side.
int spark = context.LoadSprite("spark.png", frames: 6);
Visual? aura = Fx.Play(player, spark, new FxOptions { Loop = true, Under = true });
// later
aura?.Stop();
```

`Play` returns a `Visual` (`Playing`, `Stop()`, `Instance`), or `null` if there's no such unit.

| `FxOptions`          |                                                                     |
| -------------------- | ------------------------------------------------------------------- |
| `Speed`              | Frames per game frame (the game's effects mostly play at 0.5).      |
| `Loop`               | Plays until stopped (an aura) instead of once.                      |
| `OffsetX`, `OffsetY` | From where the unit is drawn (its feet): -16 is about chest height. |
| `Colour`, `Alpha`    | Its tint (`Draw.Rgb`) and opacity.                                  |
| `Under`              | Drawn behind the unit: a glow on the ground at its feet.            |
| `Light`              | The colour of the light it casts (default: the game's warm orange). |

For an animation that lasts as long as a buff, use the buff's `SetAura` (see [Buffs](/stoneforgeteam-docs/content/buffs.md)).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://stoneforgeteam.gitbook.io/stoneforgeteam-docs/content/fx.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
