System Information
Please provide the following information about your system:
- Steam Audio version: 4.8.1
- Unity version: Unity 6.4 URP, 6000.4.2f1
- Operating System and version: Windows 10
- CPU architecture: x86-64
Issue Description
Pathing volume doesn't get re-initialized when audio source is discontinuously moved and started beyond the visibility of the listener. Instead, the last volume level prior to the sound being moved is used.
This becomes problematic when utilising Object Pooling with the setup of GameObject prefab with AudioSource + SteamAudioSource, where the sound is moved to the desired position, the SteamAudioSource settings are initialized and then the AudioClip is played. When moving the sound back to the pool, the SteamAudioSource component is disabled as well as the entire instance - and later enabled only right before when playing the new sound.
Steps To Reproduce
Here are my current settings related to Steam Audio:



Note: I enable the SteamAudioSource component prior to running AudioSource.Play(), and similarly set the Spatial Blend only before playing the sound.
Steps to reproduce the behavior:
- Create a scene with a plane for floor and a wall
- Add the GameObject with the AudioSource and SteamAudioSource components (using settings above) on one side of the wall
- Place the MainCamera with the SteamAudioListener (apply reverb, baked) on the other side of the wall
- Add a ProbeBatch and bake it, as well as the reverb
- Start the Game
- In the Scene view, move the AudioSource quickly away from MainCamera, so that the wall remains between the sound and the MainCamera, occluding the AudioSource.
- The pathing volume doesn't get updated and stays at the same level as it did when close to the wall. It gets updated only once the MainCamera/listener is visible again.
Alternative Scenario
In my specific case, I encounter these problems when I use single 'Main Scene', which gets a new 'Subscene A' loaded in additively. Both 'Main Scene' and 'Subscene A' have their own ProbeBatches (baked separately, with each of the scenes loaded in the Editor in single-mode prior to the bake). If the MainCamera is still present in 'Main Scene' (and its probe batch) when the 'Subscene A' loads, and the audio effects start in the 'Subscene A' after it is loaded, then upon entering the 'Subscene A' and enabling pathing for the previously started sounds (and settings their probe batch to the 'Subscene A'), the volume of these sounds doesn't match their position - certain sounds are much louder than they should be, until the MainCamera is moved, so there's clear visibility of the AudioSource (or the source is 'nudged' and moved in the scene editor).
The exact steps for this scenario are:
- Main Scene loads with 'ProbeBatchMain'
- Subscene A loads additively with 'ProbeBatchA'
- A SoundEffect 'TestSound' prefab is taken from Object Pool (it has AudioSource and SteamAudioSource components); it is first moved to the desired position, the steam audio settings are assigned (temporarily pathing = false, probebatch = null) and the AudioSource.Play() is called
- The MainCamera enters 'ProbeBatchA', the 'TestSound' has its pathing = true; probebatch = 'ProbeBatchA'
- The pathing volume of the 'TestSound' doesn't correspond to its current position (e.g. fully loud; disabling pathing fixes it)
- If MainCamera moves to see the 'TestSound', the volume corrects itself
Object Pooling
As for how the Object Pooling works:
- The SoundEmitter prefab has AudioSource and SteamAudioSource components, with the settings described above
- When first created, the SoundEmitter is instantiated and the gameObject is immediately disabled:
private SoundEmitter SoundEmitterConstructor()
{
var soundEmitter = Instantiate(soundEmitterPrefab);
soundEmitter.gameObject.SetActive(false);
return soundEmitter;
}
- When taken from the pool, the gameObject is enabled:
soundEmitter.gameObject.SetActive(true);
- Then the position of the SoundEmitter is set at desired position using
transform.position
- AudioClip is assigned as well as the SteamAudio properties (see the settings above)
- If contained within the same probe batch as the MainCamera (with SteamAudioListener), the pathing is set to true and pathingProbeBatch set to the ProbeBatch the MainCamera is inside of; otherwise pathing is false and probeBatch null
- Only then the component
steamAudioSource = enabled
AudioSource.Play() is called
- When sound stops playing, the
AudioSource.Stop() is called, the steamAudioSource.enabled = false and the emitter is returned to pool, causing the SoundEmitter.gameObject.SetActive(false) to be called
Workaround
When switching active probe batches, or moving the SoundEffect/MainCamera discontinuously, the following code is executed on the SteamAudioSource:
public void RecreateSource()
{
// Clear old source
SteamAudioManager.RemoveSource(this);
mSource.RemoveFromSimulator(mSimulator);
mSource.Release();
mSource = null;
// Create new handle
var settings = SteamAudioManager.GetSimulationSettings(false);
mSource = new Source(SteamAudioManager.Simulator, settings);
// Init handle with source
mAudioEngineSource.Initialize(gameObject);
mAudioEngineSource.UpdateParameters(this);
// Re-register with simulator
mSource.AddToSimulator(mSimulator);
SteamAudioManager.AddSource(this);
}
As this seems to re-initialize the pathing volume. However, it might be preferable to utilise dedicated API.
Minimal Project
Unity Package link: https://drive.google.com/file/d/1Jl3vMcw1fhUkaI3WIYx_x0Z272w-s0Th/view?usp=sharing
Contains the scene and all required dependancies/settings.
System Information
Please provide the following information about your system:
Issue Description
Pathing volume doesn't get re-initialized when audio source is discontinuously moved and started beyond the visibility of the listener. Instead, the last volume level prior to the sound being moved is used.
This becomes problematic when utilising Object Pooling with the setup of GameObject prefab with AudioSource + SteamAudioSource, where the sound is moved to the desired position, the SteamAudioSource settings are initialized and then the AudioClip is played. When moving the sound back to the pool, the SteamAudioSource component is disabled as well as the entire instance - and later enabled only right before when playing the new sound.
Steps To Reproduce
Here are my current settings related to Steam Audio:



Note: I enable the SteamAudioSource component prior to running AudioSource.Play(), and similarly set the Spatial Blend only before playing the sound.
Steps to reproduce the behavior:
Alternative Scenario
In my specific case, I encounter these problems when I use single 'Main Scene', which gets a new 'Subscene A' loaded in additively. Both 'Main Scene' and 'Subscene A' have their own ProbeBatches (baked separately, with each of the scenes loaded in the Editor in single-mode prior to the bake). If the MainCamera is still present in 'Main Scene' (and its probe batch) when the 'Subscene A' loads, and the audio effects start in the 'Subscene A' after it is loaded, then upon entering the 'Subscene A' and enabling pathing for the previously started sounds (and settings their probe batch to the 'Subscene A'), the volume of these sounds doesn't match their position - certain sounds are much louder than they should be, until the MainCamera is moved, so there's clear visibility of the AudioSource (or the source is 'nudged' and moved in the scene editor).
The exact steps for this scenario are:
Object Pooling
As for how the Object Pooling works:
soundEmitter.gameObject.SetActive(true);transform.positionsteamAudioSource = enabledAudioSource.Play()is calledAudioSource.Stop()is called, thesteamAudioSource.enabled = falseand the emitter is returned to pool, causing theSoundEmitter.gameObject.SetActive(false)to be calledWorkaround
When switching active probe batches, or moving the SoundEffect/MainCamera discontinuously, the following code is executed on the SteamAudioSource:
As this seems to re-initialize the pathing volume. However, it might be preferable to utilise dedicated API.
Minimal Project
Unity Package link: https://drive.google.com/file/d/1Jl3vMcw1fhUkaI3WIYx_x0Z272w-s0Th/view?usp=sharing
Contains the scene and all required dependancies/settings.