0

Applying sounds to the Bolt Platformer tutorial, help needed!

Ancoreig 2 years ago updated by GhostAegis 2 years ago 1

Hello!


I just finished the bolt platformer tutorial. I am applying some sounds (music to the main menu, a sound effect when the door is entered...)

I tried to apply a sound effect when the player pick up the key but the sound doesn't reproduce. Here is my graph:


I added the source code component to the prefab. Also, the console log says nothing :/ Any idea what is happening here? Thanks in advance

Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):
+2

It's a little hard to know without the context of what the macro is being applied to, but it looks like you're destroying the audio source as soon as you tell it to play. Thus, it never plays (because it's removed from the scene in the same frame in which it is told to begin playing).

There are loads of ways you could solve this, but the simplest would probably be to use the destroy node with the T input that adds a delay before executing destroy. Then just set the delay to be longer than the audio clip. I think that should work.