How do to 3D panning on camera, attenuation on character

,

I have the same question that was solved several years ago here: Set up 3rd listener on 3rd person camera and attenuation on character

In terms of doing this in Unreal, is the approach the same? If I do this on tick, would that work, or would it conflict with FMODStudioModule::UpdateListeners() which seems to be bound to a tick function driven by UE’s media clock. Would I need to set up my tick function the same way in order for it to not cause issues?
I could also just modify the FMOD plugin if needed

Thanks!

Turns out it’s much simpler than that! Just need to override GetAudioListenerPosition in your player controller:

void AGNPlayerController::GetAudioListenerPosition(FVector& OutLocation, FVector& OutFrontDir, FVector& OutRightDir) const
{
	Super::GetAudioListenerPosition(OutLocation, OutFrontDir, OutRightDir);

	if (const APawn* CurrentPawn = GetPawn())
	{
		OutLocation = CurrentPawn->GetActorLocation();
	}
}
1 Like

This works awesomely good and I’m surprised that this post does not have dozens of answers and that no one thanked you yet, so here’s my gratitude.

To keep the love going and in case anyone else wants to do this and doesn’t know how to, like me an hour ago, here’s what I did for it to work.

You need to override Unreal’s built-in PlayerController.

In my case, the programmers already had a PlayerController class to override some of the functions, so I just needed to paste Jeremy’s piece of code into the .cpp of my game’s PlayerController, changing AGNPlayerController for the name of your class.

Then in the .h file you’ll need to add:

virtual voidGetAudioListenerPosition(FVector& OutLocation, FVector& OutFrontDir, FVector& OutRightDir)const override;

And enjoy perfect panning and attenuation.

Thanks!