# Unreal Engine: Game Effects

*2025-10-08*

> Notes taken from the fifteenth week of Game Programming Foundations


After covering the complex but incredibly powerful [Gameplay Ability System]({{< relref "/posts/2025/unreal-engine-14-gameplay-ability-system" >}}) last week, this week **revisited** game effects – a deeper look at [Niagara Systems](https://dev.epicgames.com/documentation/unreal-engine/creating-visual-effects-in-niagara-for-unreal-engine), [Niagara Emitters](https://dev.epicgames.com/documentation/unreal-engine/getting-started-in-niagara-effects-for-unreal-engine), [Sound Effects](https://dev.epicgames.com/documentation/unreal-engine/working-with-audio-in-unreal-engine?lang=en-US), and [MetaSounds](https://dev.epicgames.com/documentation/unreal-engine/metasounds-in-unreal-engine?lang=en-US).

---

## Niagara VFX

**Niagara VFX** is the primary tool for particle effects in modern Unreal, using both CPU and GPU resources. C++ manages graphics libraries, threads, and system resources, while procedures and tasks are grouped in **Niagara Emitters**. Each **Niagara System** can run and manage multiple Niagara Emitters.

## Niagara Systems

- Adding a Niagara System opens with pre-designed templates
- Can also create an **Empty Niagara System**

## Niagara Emitters

- Similarly, adding a Niagara Emitter provides templates or an empty emitter to start from

## Opening a Niagara System

- The **System Overview** panel includes **Add Emitter**
- Pre-designed templates can be added (e.g., `NE_01`)
- **Parameters and User Parameters** panels expose programmable values
- To add a parameter: click **+** in the User Exposed area, then assign a default value in the User Parameters panel
- A vector parameter can be made and its default set the same way – parameters can accept various objects like actors, tools, or subsystems

## Using Parameters and Attributes

The Niagara System is an **Actor Component** that gets added to an actor:

- In the Details panel → Niagara → Niagara System Asset
- The **Activation** dropdown sets activation mode
- Use **Activate** and **Deactivate** Blueprint nodes

To communicate with Niagara from code, two methods exist for setting vector parameters:

1. Effects/Components/Particle System/Set Vector Parameter
2. Niagara/Set Niagara Variable (Vector2/3/4)

**Options from the Niagara category are recommended.** Both require the **Parameter Name** and **InVariable Name** text fields to match exactly with the parameter/attribute from the Niagara system. If the variable name is wrong or doesn't exist, nothing will happen – silently.

## Niagara Emitters (Technical Breakdown)

Emitters are where particles are generated – controlling how they're born, how they age, and how they look and behave. Emitter modules execute from top to bottom; the final block defines the render object (sprite, mesh, light, decal, etc.).

**Steps in an emitter:**
1. Source of processing sits at the top of the emitter box
2. CPU or GPU (or both) can be customised – useful for scaling down to simple devices like smartphones
3. Set the number of particles rendered per frame – can be tied to a "controlling" attribute based on target hardware
4. Set each particle's properties
5. Add a module to apply particle location
6. Final step: particles must change frame-by-frame as they age

**Debugging:** Right-click an emitter → **Watch Emitter in Niagara Debugger**

## Sound Effects and MetaSounds

**MetaSounds** is the high-performance audio system replacing Sound Cues:

- Offers scripting and DSP graph control
- Upgrading to newer engine versions may require rebuilding MetaSounds

### Audio Standards and Concepts

- Tempo and Rhythm
- Melody Generation
- Synthesising
- Crossfade
- Filtering
- Enveloping
- Effects Processing

### MetaSound Object

Each MetaSound object is its own audio rendering engine, capable of rendering in parallel with potentially independent formats. The pattern mirrors materials:

- Animation posts data refresh and rendering each frame
- Materials use float vectors (Red, Green, Blue, Alpha)
- MetaSound follows the same paradigm

The editor provides two triggers and one output:

- **Triggers** are equivalent to events in Actor Blueprints
- Multiple sound Blueprint nodes can be activated by a single trigger

**Creating a trigger:**
- Click **+** in the Inputs panel
- Change variable to **Trigger** in the Details panel
- Activate via Blueprint code or the Simulate button (under Default Value → Default)

**Playing sound:**
- Right-click → **Wave Player** node
- Create and edit variables assigned to each pin
- **WaveBank** is an array of audio files

**Testing:**
1. Press play button on the editor (fires the default On Play trigger)
2. Spawn a MetaSound object → automatically triggers On Play

MetaSounds render **asynchronously** and support:
- 16-bit, 24-bit, and PCM-formatted .wav files
- Ogg-Vorbis, AIFF, FLAC
- Internally converted to 16-bit PCM

## MetaSound Parameters

Parameters accept input the same way material instances do:

- Send parameter name and value to the MetaSound object
- Execute **Trigger Parameter** node with trigger as the In Name pin
- Combine triggers using **Trigger Any**
- Use **Set [data type name] Parameter** Blueprint node - the parameter name must match the In Name pin value
- Use **Play** node to trigger playback

## MetaSound Lifecycle

Each MetaSound object has an **OnFinished** output trigger. When activated, the MetaSound stops processing sound and removes itself. Any reference to the object becomes invalid – which can cause error messages or crashes.

**Two management strategies:**

1. **Avoiding invalid references:**
    - Maintain a list of audio files and sound effects
    - Prioritise based on period of activation (e.g., weapons stay loaded, end-level sounds can unload)

2. **Using other MetaSound objects:**
    - Right-click → Graphs → Other MetaSound objects
    - Activate via trigger, pass parameters, mix audio output
    - Can use **Mixer** Blueprint node to blend sounds

---

## Notes on things that stood out

This week felt like the second pass on [Week 11]({{< relref "/posts/2025/unreal-engine-11-visual-and-audio-effects" >}}) – same topics, but the course went deeper into the *how* rather than the *what*. The most useful takeaway was the parameter naming discipline: mismatched names fail silently, which is the worst kind of bug in a system this layered.

The MetaSound lifecycle note ("any reference becomes invalid") is genuinely scary – if you're keeping references to MetaSound objects after they finish, you're one frame away from a crash. The prioritisation strategy (keep weapons loaded, unlevel background sounds on demand) is the kind of practical guidance that saves hours of debugging later.
