AudioStreamPlayer3D only works when tested in viewport, and in game it doesn't

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By yatoimtop

So I’m trying to have positional audio in my game, like when you turn on a radio the sound comes from the radio, or when you’re at the top of a lighthouse you hear a song.

The problem is that every time I try to use a AudioStreamPlayer3d, it never works in game. I’ve tested the function of it working in separate blank projects, and it works there, however it just doesn’t work at all in my game. I’ve tried adding a listener, I’ve tried already tried adjusting the distance and unit size. The weird part is that when i click the playable box to test it in viewport, it works just fine.

One thing to note is that I did start the project out with a premade first person controller, but I’ve already tried replacing the camera. I also opened another project with the premade first person controller, and it works there. Additionally, the normal AudioStreamPlayer works fine. It’s only the AudioStreamPlayer3d that’s having issues. Is there a hidden setting or piece of code I have to turn on? I’ve been trying to fix this issue for 3 days so any help is appreciated!

edit: i figured it out, i had the camera in a viewport node and there’s a setting you have to enable in the viewport node to have 3d audio.

:bust_in_silhouette: Reply From: yatoimtop

I figured this out, so I might as well update this. If your audio node is in a viewport, you need to enable audio in the viewport node in the property window on the right.

Thanks for this. Solved the issue for me :slight_smile:

elim | 2022-08-03 11:08

1 Like