Change Audio Listener in C++

Greetings,

I’m working on a 3rd person shooter recently, and I’m using UE4.16 and Wwise 2017.1.2.6361. I’m trying to change the audio listener from the camera to the character itself. I know there is SetAudioListenerOverride, but in blueprints.

Is there a way to do it in C++? Or maybe there’sa setting I can change in either Wwise or UE that I’m missing?

You would have to confirm how wWise gets listener information and override that. It’s not necessarily going to be due to SetAudioListenerOverride.

Also, it’s probably a bad idea to do what you’re trying to do. Setting the listener to a character (for a 3rd person game) is generally going to result in poor results. This is because 3d panning will be odd/unexpected as objects move around your character. I.e. it will sound like a sound is behind you when the sound is behind your character and is generally not what players expect.

Generally, 3rd person listeners are setup to derive panning from the camera position and distance attenuation from the character position. It’s counterintuitive but is generally the best method for 3rd person cameras.

Yeah, I asked the question on the Wwise forums and still waiting for an answer, because I couldn’t find any documentation on how they set up their listener in UE4.
And yes, when I asked this question, I was planning to attach the listener to the character mesh, to have correct attenuation, however, when it comes to the rotation, I was planning to pass the camera rotation. My issue is I don’t know how to do it in C++.

Yeah, if you were using native UE4 engine, I could suggest a path. It’s on my list of features to add in UE4 and I even have an old changelist where I sketched it out. There’s a few tricky bits w/ respect to some hard-coded ways which the native engine gets “distance from listener” and how to deal with split screen, but it’s pretty doable in native UE4.

That seems neet. Unfortunately, we’re using Wwise in our project, that’s why I mentioned it in the question because I know they approach things differently. I’m trying different things currently, and if I fix it, I’ll post the solution anyway to help other people that might face the same problem. Thanks for the response regardless, I really do appreciate it.

So I figured out a way to do this. So the Wwise plugin creates an AkComponent under the PlayerCameraManager at the beginning, and it uses SetAudioListenerOverride to set that as the listener. Since I needed to have the character as the actual listner, I called SetAudioListenerOverride to set the mesh as the new listener, and from what I understood, that linked the listener position to the mesh, which did the job for me. I faced other issues like having multiple listeners created under the PlayerCameraManager (I still dont know why, maybe because that call is net multicast, and it’s creating a listener for each PlayerCameraManager?! I’m not sure), but I fixed that too.

@Minus_Kelvin thanks for the help.