Hello! We are having strange bug in our project in Unity (2022.3.20f1) using Wwise 2023.1.4.
Because of maps in game are procedurally generated we are adding prefabs with Multi Position type ambient sources (Ocean and Lakes) through code.
But something went wrong, and every time with new map there's extra sounds are adding in the air, where it shouldn't be (due to top down view it is very noticeable). And this extra source plays both, Lake an Ocean in one place.
Profiler shows nothing weird. One thing I've noticed that attenuation window shows that this extra source is playing always second to last, or last spawned prefabs of Lake and Ocean , although this prefabs are still on their right places in game, when I check them in editor view.
In Wwise I've tried almost everything I could think about - changing to different attenuations, voice behaviours etc. - but with no results.
All prefab settings are checked - its static, multi position is on.
Here's also the parts of code responsible for creating and placing prefab in game.
public GameObject SpawnGO(string holderName, Vector3 position, GameObject goToSpawn, float rotation = 0, bool playAnimation = false, bool castShadows = true, string sendSoundEvent = null, GameObject soundEventGo = null)
{
GameObject go;
go = Instantiate(goToSpawn, GetHolder(holderName));
go.transform.localPosition = position;
go.name = goToSpawn.name;
go.transform.rotation = Quaternion.Euler(0, rotation, 0);
if (playAnimation)
AnimationController.Play(go, WorldAnimationController.EType.Spawn, null, true, sendSoundEvent, soundEventGo);
if (go.GetComponent<MeshRenderer>() != null)
go.GetComponent<MeshRenderer>().shadowCastingMode = castShadows ? UnityEngine.Rendering.ShadowCastingMode.TwoSided : UnityEngine.Rendering.ShadowCastingMode.Off;
else
{
var meshes = go.GetComponentsInChildren<MeshRenderer>();
foreach (var mesh in meshes)
mesh.shadowCastingMode = castShadows ? UnityEngine.Rendering.ShadowCastingMode.TwoSided : UnityEngine.Rendering.ShadowCastingMode.Off;
}
return go;
}
public void SpawnAmbience()
{
List<Vector2Int> shoreTiles = new List<Vector2Int>();
List<Vector2Int> lakeTiles = new List<Vector2Int>();
for (int i = 0; i < playData.depthMap.GetLength(0); i++)
{
for (int j = 0; j < playData.depthMap.GetLength(1); j++)
{
if (playData.depthMap[i, j] == -InfoManager.Instance.oceanDepthForAmbience && playData.GetTile(i, j).terrainType == ETerrainType.Ocean)
shoreTiles.Add(new Vector2Int(i, j));
else if (playData.depthMap[i, j] <= -InfoManager.Instance.minLakeDepthForAmbience && playData.GetTile(i, j).terrainType == ETerrainType.Lake)
lakeTiles.Add(new Vector2Int(i, j));
}
}
shoreTiles = FindIntervalPoints(shoreTiles, InfoManager.Instance.oceanAmbienceInterval);
lakeTiles = FindIntervalPoints(lakeTiles, InfoManager.Instance.lakeAmbienceInterval);
foreach (var tile in shoreTiles)
SpawnGO("Ambience", tile.ToWorldPositionXZ(new Vector2(0.5f, 0.5f), 5f), InfoManager.Instance.oceanAmbiencePrefab);
foreach (var tile in lakeTiles)
SpawnGO("Ambience", tile.ToWorldPositionXZ(new Vector2(0.5f, 0.5f), 5f), InfoManager.Instance.lakeAmbiencePrefab);
List<Vector2Int> FindIntervalPoints(List<Vector2Int> allTiles, int distance)
{
List<Vector2Int> output = new List<Vector2Int>();
if (allTiles.Count == 0)
return output;
int sqrDistance = (distance * distance);
while (allTiles.Count > 0)
{
var addedTile = allTiles[0];
output.Add(addedTile);
allTiles.RemoveAll(x => (x - addedTile).sqrMagnitude <= sqrDistance);
allTiles.Sort((x, y) => (x - addedTile).sqrMagnitude.CompareTo((y - addedTile).sqrMagnitude));
}
return output;
}
}
Please, help...)
Where the problem can be?