SpawnSoundAttached - IsAudibleSimple location problem

MSTF
Mon, 09 Nov 2015 10:38:18 +0000
Audio

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

5 posts - 1 participant