Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Tracked by #76797
ndarilek opened this issue Sep 26, 2019 · 7 comments
Open
Tracked by #76797

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

ndarilek opened this issue Sep 26, 2019 · 7 comments

Comments

@ndarilek
Copy link
Contributor

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:

  • Create a separate Viewport.
  • Create a Camera as a child of the viewport. I don't want 3-D rendering, so I hope this prevents any visible rendering.
  • Create a Listener as a child of that camera.
  • Enable the 3-D listener property on the parent Viewport.

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
Copy link
Member

KoBeWi commented Sep 13, 2020

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 4372569 btw

@KoBeWi KoBeWi changed the title Listener silently fails if it isn't a child of Camera Listener doesn't output sound if there's no Camera on the scene Sep 13, 2020
@ellenhp
Copy link
Contributor

ellenhp commented Sep 23, 2021

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
Copy link
Member

KoBeWi commented Sep 23, 2021

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
Copy link
Contributor

ellenhp commented Sep 23, 2021

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
Copy link
Member

Calinou commented Sep 23, 2021

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

@akien-mga
Copy link
Member

akien-mga commented Sep 23, 2021

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
Copy link
Contributor

ellenhp commented Sep 23, 2021

Perhaps listeners should also work independently of cameras?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants