Godot Version
Version: 4.2.1
Question
For some reason when multiple AudioStreamPlayers play, I’d get this issue where it feels like they’re playing over each other?
I tried to rearrange them into arrays so that the last played sound would be removed but it just altered the feel of the game too much.
So I’d like to know what would be the case at hand.
In this footage you can notice how, whenever the enemies are hit, and there are other SFXs playing, it just sounds irritating to the ear.
It becomes more obvious when at the end of the game all the movement sounds play at the same time and it’s just a very annoying cacophony.
https://files.catbox.moe/2p7p1x.mp4
What should I do? In the following link is my nodes layout.
https://files.catbox.moe/0brm97.png
And the code for this Node related to SFXs is the following:
public partial class EnemyLogistics : Node2D, IRecipient<SYSMessages.ProjectileHitsAlien>, IRecipient<SYSMessages.EnemyTouchesBorder>
{
private bool enemyProjectileActive = false;
private int invadersLoop = 0;
public List<AudioStreamPlayer> InvadersMovement = new List<AudioStreamPlayer>();
public AudioStreamPlayer InvaderKilled { get; set; }
public Timer EnemyTimer { get; set; }
private static bool stageCleared;
private List<Enemy> Aliens = new List<Enemy>();
private bool goingRight = true;
private bool goingDown = false;
public override void _Ready()
{
base._Ready();
int i = 1;
while (GetNode($"Movement{i}") != null)
{
InvadersMovement.Add((AudioStreamPlayer)GetNode($"Movement{i}"));
i++;
}
InvaderKilled = (AudioStreamPlayer)GetNode("InvaderKilled");
EnemyTimer = (Timer)GetNode("EnemyTimer");
stageCleared = false;
var nodes = GetTree().GetNodesInGroup("Enemies");
foreach (var node in nodes)
{
if (node is Enemy enemy)
{
Aliens.Add(enemy);
}
}
}
private void OnEnemyTimerTimeout()
{ StrongReferenceMessenger.Default.Send<SYSMessages.InvadersAnimation>(new(true));
InvadersMovement[invadersLoop].Play();
if (invadersLoop == 3)
{
invadersLoop = 0;
}
else
{
invadersLoop++;
}
EnemyMovement();
}
public void Receive(SYSMessages.ProjectileHitsAlien message)
{
//Registers the sounds playing in a list in order to remove them properly when they start playing over each other
InvaderKilled.Play();
EnemyTimer.WaitTime -= 0.0155;
int alienToDelete = 0;
foreach (Enemy alien in Aliens)
{
if (alien.GetRid() == message.enemyId)
{
break;
}
else
{
alienToDelete++;
}
}
Aliens.RemoveAt(alienToDelete);
StageCleared();
}
}
I’m thankful for all the help possible. This issue is just making me a bit peeved.