Hello! I wanted to ask about a way to spawn sound actors randomly around the player, and it will pick random sounds to spawn. I have an idea on how it will pick random sound, but I do not know of a way on how to spawn them with enough randomness around the player.
Make a custom event called “PlayARandomSound”
Make this event pick one sound randomly out of an array of sounds that is a blueprintable variable on your player. There’s an easy way to pick a random element of an array.
Create a random location around the player by adding random values to X and Y and Z locations. Spawn a sound (cue, really) in the world using the picked sound and location.
Set a timer for a random amount of time, between something like 0.8 and 8 seconds (for example) – the min and max times could also be parameters on the player blueprint. Make sure to store the event handle into a variable on the blueprint (overwriting the previous one.) The timer should call back to the PlayARandomSound event.
In Event Being Play, call the PlayARandomSound event to get the cycle started.
Note that I packed the blueprint nodes tight to fit in a single screen shot.
Also, the location distribution will be slightly skewed towards front-left, front-right, rear-left, and rear-right, because of the box sampling rather than sphere sampling, but that is typically not particularly noticeable because sound localization is very imprecise, and sounds play seldom. If you want another random-position sampling function, you can substitute that instead.
There’s also a Beta plugin in Engine called Soundscape
Soundscape procedurally generates ambient sounds which are streamed as the player moves around the world. Once set up, the plugin manages and composes these sound systems autonomously and removes the need to manually create them.
Amazing! Thank you for your time and easy explanation. I have recreated it on my side and it works. Thanks for the help.
Thanks for the recommendation! I looked at the documentation and it says it can do what I want. I will be testing it out on another project to see if it works. I appreciate your time and help!
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.