Audio Control

The Storm Environment: Lightning and Thunder VFX package includes three key scripts that manage all audio playback and transitions for rain and thunder effects.

If you use the prefabs with sound effects (SFX) in your own scenes, make sure to include the SFXManager prefab as well. Without it, the audio scripts won’t be able to locate the manager, resulting in errors and missing sound playback.

AudioFadeIn

The Rain SFX prefab includes the AudioFadeIn script, which provides fine control over the attached Audio Source.

Key Features:

  • Start Delay: Set a delay before playback begins to align the rain sound with the first visible raindrops.

  • Fade Curve: Control how quickly the sound reaches full volume over the fade duration.

  • Loop: Choose whether the audio loops infinitely or stops after one playthrough.If looping is disabled, the created Audio Source will automatically be destroyed once the clip has finished playing (plus any defined delay).

ParticleSoundTrigger

Used primarily for lightning effects, this script triggers sound playback each time a new particle (e.g., a lightning bolt) is spawned.

How to Use:

  • Attach the script to your lightning particle system.

  • Assign one or more thunder sound clips.

  • Each time a lightning particle appears, the script randomly selects and plays one of the assigned clips.

SFXManager

The SFXManager acts as the central controller for all sound playback. It handles the creation and management of Audio Sources, ensuring that every sound is properly instantiated and cleaned up.

Functionality:

  • Called by both AudioFadeIn and ParticleSoundTrigger scripts.

  • Provides methods such as PlayRandomSFXClip() and FadeIn() for consistent and controlled sound behavior.

  • Must always be present in the scene when using prefabs or scripts that rely on audio playback.

Last updated