godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.2k stars 19.97k forks source link

Listener doesn't output sound if there's no Camera on the scene #32367

Open ndarilek opened 4 years ago

ndarilek commented 4 years ago

Hit this when trying to use AudioStreamPlayer3D in a 2-D world to get its advanced panning/rotation support. Essentially I'm syncing the X and Z coordinates of AudioStreamPlayer3D nodes with the X and Y coordinates of a Node2D parent, as well as their rotations. This seems to work OK for sound sources, but it failed for Listener and took days plus help to debug.

Essentially, I can't have a Listener as a child of a Node2D (or even a Spatial) and get audio. Instead, I have to:

Once I've done that, I can sync AudioStreamPlayer3D nodes with a Node2D parent. I can also sync the Listener with another Node2D, but I can't use the parent-child relationship. I have to tag it.

I looked through the listener source, and don't immediately see where it would fail if there isn't a Camera in its ancestry.

Here is a fairly minimal reproduction of what I tried and failed. The reproduction uses a Spatial as the Listener parent, but it'd also be nice if I could use a Node2D. I figured a Spatial parent would be the least likely to fail though, but it did.

Using a custom built Godot 3.1.1.

Thanks.

KoBeWi commented 3 years ago

The title is inaccurate. This happens if there's no Camera in the scene, so 3D rendering is inactive. This might be intended and just needs being documented.

EDIT: Still valid in 43725691b btw

ellenhp commented 2 years ago

I think @Calinou may have mentioned wanting to add a warning if there are 3D nodes in the scene but no 3D camera. Is that an appropriate way to address this? I don't want users spinning their wheels trying to figure out why the pattern they used for 2D doesn't work in 3D, but at the same time I think that the current behavior does make sense to keep. So documenting it and maybe adding a warning seems like the best plan here.

KoBeWi commented 2 years ago

If there is any use-case for sound-only 3D and it can be added without introducing overhead etc. then it could be fixed.

If not, adding a warning is ok.

ellenhp commented 2 years ago

There's absolutely a use-case for sound-only 3D. @ndarilek can expand on why if he's available but the basic version is that Godot does not support first-person audio listeners in top-down 2D games. I wish I was around for more of the 4.0 development cycle because there are so many things I'd like to rework. That's something that I wish we could support, for example.

Calinou commented 2 years ago

I think we only have the Doppler effect in 3D, so having support for audio-only 3D makes sense too.

akien-mga commented 2 years ago

Sound-only 3D can be used to make games suitable for visually impaired players, such as AudioQuake, where sounds are used as spatial cues instead (or additionally to) 3D models. If this can be supported that's definitely nice to have.

ellenhp commented 2 years ago

Perhaps listeners should also work independently of cameras?