Play Audio Clip
Play Audio Clip starts character-centered sound through Opsive Shared Audio. The Character Effect tracks a lifetime based on raw clip length; Shared Audio owns the Audio Source and playback. Use it for a normal one-shot, with explicit audio ownership for early termination or more complex playback.
Configure a valid one-shot
- Add Play Audio Clip under Ultimate Character Locomotion > Effects, keep it enabled, and select its row.
- Set Inspector Description: Damage Voice. Expand Audio Clip Set, leave Audio Config empty, and assign one playable clip to Audio Clips.
- Keep every selectable clip non-null. Use effective audio settings with loop off, pitch 1, and zero delay for the first test.
- Ensure Shared Audio, its Audio Source prefab/default, an Audio Listener, and the Opsive Scheduler are available and active.
- Configure the damage, ability, or code trigger through the shared Effects setup. For an enable-triggered test, disable the row, select Start When Enabled, then enable it in Play Mode.
- Trigger once. A Shared Audio source should appear or be reused beneath the character, the clip should play, and (Active) / State should clear at its raw length.
Sequence Character Effects one at a time. Let this instance finish naturally before reusing it. After an early stop, wait until its original raw-clip deadline has passed before restarting the same instance; use a custom audio-owning system when immediate cancellation/retriggering is needed.
Choose one clip source
| Field | Default | Decision |
|---|---|---|
| Audio Clip Set > Audio Config | Unassigned | When assigned, the config supplies clip selection and source settings. Populate its clips before triggering. |
| Audio Clip Set > Audio Clips | Empty | Used when no Audio Config is assigned. Assign a valid clip to every entry. |

Choose one authoritative source: a populated Audio Config or the inline list. An assigned config takes precedence over the inline list; do not treat that list as its fallback. Check the selected/default Audio Source prefab contains an Audio Source.
A new Audio Config uses Clip Selection: Random, no explicit Audio Source Prefab, Share Audio Source enabled, Replace Previous Audio Source disabled, Copy Existing Audio Source Properties enabled, and no Audio Modifier overrides. Sequence and Index selection are also available. Keep source replacement off when existing sound should continue; use a reserved/config-owned source where independent playback is required.
For the complete source, spatial blend, mixer, and modifier setup, continue with Audio. Actual source/default settings determine audibility, looping, pitch, and delay.
Coordinate Effect and playback lifetimes
The Effect requests audio for the character root. Shared Audio selects/creates a source in that GameObject’s group and normally parents newly instantiated SharedAudioSource or ReservedAudioSource objects beneath it.
The Effect schedules its own stop from audioSource.clip.length. That raw duration is independent of playback modifiers:
| Playback choice | Ownership requirement |
|---|---|
| Pitch 1, no delay, no loop | Standard one-shot baseline; compare sound completion and Effect lifetime. |
| Lower/higher pitch | Playback duration changes; own completion separately when exact synchronization matters. |
| Delayed playback | Include the delay in the audio owner’s completion policy. |
| Looping or faded playback | Use a system that explicitly owns source stop/fade and completion. |
| Early Effect stop/disable | Stop the sound through the audio-owning API as well when termination is intended. |
The Effect retains no playback handle and its stop hook does not stop/fade the Audio Source. The base State still activates/clears with the Effect lifetime. Use a custom owner that retains the correct PlayResult when sources can be shared or reused; a later reference may identify another playback.
A start while this instance is active leaves the existing playback and deadline unchanged. An ability’s Start Effect Name supplies only the start, so coordinate completion explicitly when it should follow that ability. Use lifecycle overrides for custom notifications; this Effect has no dedicated completion UnityEvent.
Verify sound and completion
- Trigger a valid one-shot and inspect the actual source beneath the character. Confirm the intended clip, spatial blend, mixer output, and one audible playback.
- Confirm (Active) and State clear at the raw clip length. Repeat after natural completion.
- Test any early-stop owner separately, confirming both source playback and Effect state follow the intended policy before permitting re-entry.
- For pitch/delay/loop/fade requirements, test the dedicated audio owner’s completion and source-reuse behavior.
- In multiplayer, replicate the gameplay event and invoke one local sound path for each intended listener. Avoid duplicating the same event through both world audio and a local Effect.
For missing sound or completion, validate every selectable clip, source prefab/default, Scheduler, listener, and effective source settings before retesting. Character Effects have no built-in network synchronization.
PlayAudioClip.AudioClipSet exposes the set; its AudioConfig and AudioClips select the source. Retrieve a configured non-null Effect with GetEffect<PlayAudioClip>() and use locomotion’s TryStartEffect / TryStopEffect for its lifecycle. Shared Audio remains responsible for playback control.