There is a simple way to play a sound in Blueprints. Just use the action "Play Sound at Location":
In this action choose in the combobox the sound to play. In parameter "Location" can be used the position of the Actor related to the sound. Imagine that the above example is a Blueprint of some type of explosive. When the player touches the explosive, the sound is played in the location where the Blueprint is.
The best way to have control over sounds in the Blueprints is using "Audio Component". As an example, imagine that there are two songs. One is the music that plays during the game and the other is a victory music that plays when the goal of the game is reached.
To add a song click on the "Add Component" button of a Blueprint and choose "Audio". Create two "Audio Component" with the name "GameMusic" and "VictoryMusic". For each of them, in the "Details" tab, select in the combobox "sound" the song that will be used and uncheck the property "AutoActivate" so that the song does not start playing automatically.
A Custom Event was created with the name "Victory" that must be called when the goal of the game is reached. The actions "Fade Out" and "Fade In" were used to gradually change the music for 2 seconds. The image below shows the transition between the songs:
|Click to enlarge|
Table of Contents