So, i really want to use the audio occlusion feature, but i think i am misinterpreting what the line of sight within the description really means for this feature?? I have an ambient sound cue that has the enable occlusion on, this soundcue sits in a large room that can be enter either from top or bottom, when i am flying around in the editor and i have realtime audio at full volume, the audio occlusion feature works exactly as i expect it. Once i am behind a door, i hear it occluded and when i enter the room, i can hear the filter open up. but when i play in the editor, its the opposite? Also, if i enter the room while looking at the sound source direction i’ll hear it occluded but if i turn around i won’t? so i find it bizarre that the feature seems to work while in the edit but when i play test its off. i made sure not to have sound focus on, just in case that was causing a non-focus attenuation problem, which it isn’t.
So my question is, why is my audio getting occluded when i look at the direction of the audio source but when i turn around i lose the occlusion? it is because of the “line of sight”? does the line of sight work from my camera (casting a linetrace) to an audio emitter and does it determine if something (with collision) is in between? because if that’s the case, then something is really wrong. can someone please help me understand this feature better?
Are you playing with 3rd person camera when in-game? The occlusion feature currently only works from the listener position, not the character position, which is usually attached to the game viewport/camera. In 3rd person games, this can be a bit weird – I suppose it’s a reasonable feature addition to add the option to perform the trace from the position of the player controller/pawn rather than from the listener position (or viewport position).
I recently added the ability (4.12 feature) for users to define their own trace channel to use (it’s currently using Visibility) so you can more tightly control what geometry causes audio occlusion.
Thanks for the reply, well yes and no actually, we do have a 3rd person camera but also a 1st person camera. we can choose which view we want by pressing V. so i am wondering if by having a 3rd person camera behind my character and although i am using the 1st person camera (inside our ship), its default the listener position to the 3rd person camera?? maybe i’ll try removing the 3rd person camera altogether and see if that does the trick, but if it doesn’t do you suggest another work around?? and yes it would be a great feature if we can choose where does the trace start or from what camera we can choose to have the listener position be.
Unfortunately, there isn’t a work around without modifying code at the moment. However, it would be pretty straightforward to experiment with doing the trace from a player controller’s pawn. If you want to modify the source to try it out, the place to do it would be FActiveSound::CheckOcclusion.
// Default trace location is the listener location
FVector TraceLocation = ListenerLocation;
// Temporary branch -- would probably add this as a flag to the AttenuationSettingsPtr object
bool bUsePlayerPawnForTraceLocation = true;
if (bUsePlayerPawnForTraceLocation)
{
// Get the player controller pawn if it exists and override the trace location
if (APlayerController* PlayerController = UGameplayStatics::GetPlayerController(WorldPtr, 0))
{
if (APawn* PlayerPawn = PlayerController->GetPawn())
{
TraceLocation = PlayerPawn->GetActorLocation();
}
}
}
if (bOcclusionAsyncTrace)
{
WorldPtr->AsyncLineTraceByChannel(SoundLocation, TraceLocation, ECC_Visibility, Params, FCollisionResponseParams::DefaultResponseParam, &OcclusionTraceDelegate);
}
else
{
bIsOccluded = WorldPtr->LineTraceTestByChannel(SoundLocation, TraceLocation, ECC_Visibility, Params);
}
I just threw this code together and tested it this afternoon and it appears to work pretty well in the case of a 3rd person camera (i.e. sounds are still occluded behind a barrier if camera can see but actor pawn can’t). We just missed the feature deadline for 4.12 but I will try and see if I can add something like this for 4.13.
Hello, apologies for bumping this old thread, but as of 5.2.1, this does not appear to be the case. I am using the attenuation (occlusion) settings described, with the audio listener override attached to the player character, and yet the trace for occlusion is occurring between the audio source and the camera. Is there any way to change this that doesn’t require C++?