Realistic speed of sound?

I am looking for a way to make sounds played not instantly but with a delay based on distance from the sound source. For example someone fires their weapon 300 meters away from me, I first see the flash, then the bullet arrives, then, about 1 second after the initial flash I hear the sound of a shot being fired. I have in mind some ways to achieve this, but they are all relatively complicated and prone to bugs, like manually cycling through characters, doing some checks, playing sounds for them and so on. But maybe there is a more simple way to achieve this effect, that I have overlooked? If it can not be done or difficult to do with Blueprint then some C++ is ok too.

Ok, I started playing with it, trying things out the way I see it so I quickly made this:


And that’s it, it just works, but I don’t know why. I mean, I expected it to work the way it does with just one player. But it also works just fine with multiple players, everyone get their proper delay, depending on how far from the explosion they are. Even though there is player index 0 in Get Player Pawn node. I expected it at this point to play the sound for everyone based on player 0 position. Or maybe if there were 2 players then I could expect it to play 2 times for every player, that wouldn’t surprise me. I thought it was nowhere near finished, no iterating through every player, no measures taken to make sure everyone hears what they supposed to hear and not someone else…

If anyone knows why it works like this, please let me know.

Have you looked at Timelines?

I have used timelines for other things, I think it is a bit of an overkill to use a timeline for my current task, simple delay is just enough. Unless there is something I don’t understand about timelines that makes them good for the task.

Also, I already achieved what I wanted, at this point at least. I just didn’t expect it to work and still do not understand why it works.

Im new to Blueprinting. Id love to know more about how you made this blueprint. How do I make the ‘Get Distance To’ Event class blueprint?