Audio System For Particles
Outline:
Sparks, explosions or magic spells in games are somewhat of a lie, a nice trick so to speak. They look spectacular and give the player the sensation to be part of a dynamic world with lots of interaction possibilities. They are usually used to describe the interaction of objects in the game world or as a player informant giving feedback on certain game mechanics. Particle effects usually don’t rely on the physics system of the game in terms of “real” physical impacts. What game developers do here is to “fake” physical reactions by drawing 2D-graphics on defined points (billboards) within the game world, that are always oriented at the player’s position to create the sense of a volumetric effect. Not only can you layer different graphics, you can also modify different parameters like: Amount of randomly generated images (amount of particles), size scaling of the images, direction where the images get drawn, should they be affected by physical forces like gravity or wind or how quickly they should fade out. Apart from still images, particles can also be drawn using 3D-meshes or light elements to make the illusion even better. Of course, all these techniques can be combined to create the best possible player experience.
Plan:
Animations and sound effects are as well part of what makes particle effects feel awesome. It is crucial that all elements feel like a coherent package, that the player experiences them as part of the game world. VFX are the icing on the cake, but they still need to be kept coherent to the world they belong to. For us Audio Designers, there are some things to consider: To build a very simple audio particle system, we most likely will use events from particle systems to trigger synchronized audio. These events can be triggered at the spawning point or when particles hit a physical surface etc. It’s a simple and straight forward approach to make sure that sounds play at the right time, in the right frequency and at the right place.
Implementation:
- First step is to create a new blueprint class for simple audio particle systems. You can save them under Content -> Audio -> Blueprints -> VFX -> Particles. Open the blueprint in the editor and add a particle component and an assign a particle system to that component. Browse to the particle system and open it in the cascade editor. To give the initial spark a sound, select the respective (non-GPU) sprite, right click (Event -! Event Generator) and add a new event. Select the event generator and add a new event of type “Spawn” and call it “Spawn_Burst”.
2. Go back to the audio particles blueprint, in the event graph, select the particle system component, scroll down to the “Events” section and create an “On Particle Spawn” event. We need to connect the event name output to a switch on name node, where we can enter the event “Spawn_Burst” we have created beforehand. This event will then be connected to a “Play Sound at Location” node, which will play the sound whenever the event gets called. To get the right location, we need a reference to self and extrapolate the actors’ location from that using a “GetActorLocation” node. Connect the vector location into the play sound nodes’ location pin. Assign the correct sound cue.
3. Now for the impact sounds, we need to get back into the cascade editor of the particle system and create another event of type “Collision”. Name this event, for example, “Spark_Collide”. Go back into the event graph of the audio particle blueprint and select the particle component. Go to the “Events” section and create and “On Particle Collide” event. Now connect the Event Name output to a switch on Name node to be able to filter by event name, add a pin and copy the name of the event created beforehand “Spark_Collide”. The Frequency of the event defines the probability of the sound being played. This will then trigger a “Play Sound at Location” node. The location of the particle collision is where the sound should be played, therefore connect the Location vector out of the “On Particle Collide” node to the Location input of the “Play Sound at Location” node. Since this is a physical collision, meaning the interaction of two physical objects in the game world, we can also mix in the sound of the surface the particles collides to. Connect the outlet of the “On Particle Collide” node to a “Get Surface Type” node. We then connect the surface type outlet to a “Select” node and connect it’s return value to the “Play Sound at Location” node. This automatically assigns sound cues to surface types.
4. As stated in the outline, particles are basically “drawn” light or graphic elements, with a fixed perceptive to the players’ camera. For performance reasons, these elements usually only get rendered if the player can look at them. This can have some serious implications to our audio system, since it will only play if the particles get spawned and rendered by the engine. To avoid the problem that sounds stop playing if the player turns away from them, we need to check, if in our particle system (open the cascade editor without selecting anything) under Details -> Bounds the option “Use Fixed Relative Bounding Box” is activated and properly setup. This means that the system keeps being active as long as the player stays within a certain radius, whether he is looking at the respective particle system or not. It is recommended to set up the bounding box at the same distance as the attenuation radius.