SpawnSoundAttached - IsAudibleSimple location problem

Hi,

I’m trying to play simple SoundCue. But sometimes it is not working. I debugged code and I think found the problem.

When I calling SpawnSoundAttached with KeepRelativeOffset IsAudibleSimple returning false and my sound is not playing.

// Location used to check whether to create a component if out of range
	FVector TestLocation = Location;
	if (LocationType != EAttachLocation::KeepWorldPosition)
	{
		TestLocation = AttachToComponent->GetRelativeTransform().TransformPosition(Location);
	}

	UAudioComponent* AudioComponent = FAudioDevice::CreateComponent(Sound, AttachToComponent->GetWorld(), AttachToComponent->GetOwner(), false, bStopWhenAttachedToDestroyed, &TestLocation, AttenuationSettings);
	if (AudioComponent)
	{

Here you can see, FAudioDevice::CreateComponent getting Relative TestLocation instead of World and inside this function “IsAudibleSimple” calling with RelativeLocation instead of WorldLocation.

I hope explained well because of my english.

Thanks

Hey MSTF-

Just so I understand clearly, is the issue that the sound isn’t playing or that it is not being played in the correct location? Is the code you posted part of the source or is it your own code? Where is this being called from? Are you able to reproduce the issue in a new project without additional content? If so can you post the steps that reproduced this for you?

Cheers

Sorry for bad clarification. Yes you are correct.

Sound playing in correct location but you cannot hear it sometimes in correct location.

The code is part of UGameplayStatics::SpawnSoundAttached

You can repoduce this error with steps;

  1. Spawn PlayerController/Character at location something big like 50000x50000x50000
  2. Try play sound via SpawnSoundAttached and attach to Mesh of Character with KeepRelativeOffset

And you cannot hear the sound.

Oh I forgot important thing. Your Sound duration should be less than 1 seconds. If your sound greater than 1seconds it is working fine because IsAudible forcing to true if duration greater than 1seconds :slight_smile:

So when you testing try it with short sounds :slight_smile:

Thanks

Hey MSTF,

So running some test with your set up, I think I found the source of your issue. I was able to reproduce what you are reporting, using the Spawn Sound Attached node in blueprints at the location 50,000x50,000x50,000, and playing a sound less than 1 second.

Be sure your sound does not have attenuation settings applied (Untick Attenuate). See the below images for reference.

Non-Attenuating Sound

Spawn Player Controller

Play Sound Attached

As soon as I checked the ‘Attenuate’ option on the Sound Cue I am unable to hear the sound upon pressing play in my level. However, if I uncheck ‘Attenuate’ within the ‘Sound Cue’, the sound plays just fine.

Cheers,