The SpawnSoundAtLocation() function returns a null pointer when executed in BeginPlay().
But if I execute it outside of BeginPlay() it works perfect (return a valid pointer).
Is there any other overridable function suitable for spawning audio?
The problem is caused by the “Attenuation Settings” parameter.
Audio = UGameplayStatics::SpawnSoundAtLocation
(
World,
Sound,
Location,
Rotation,
Volume,
PitchMultiplier,
StartTime,
nullptr, //AttenuationSettings,
nullptr, //ConcurrencySettings,
false //AutoDestroy
);
if AttenuationSettings=nullptr;
then it works in BeginPlay() (Audio is a valid pointer)
if AttenuationSettings parameter is got like this:
UPROPERTY(EditDefaultsOnly)
class USoundAttenuation *AttenuationSettings = nullptr;|
Or like this:
UPROPERTY(EditDefaultsOnly)
TObjectPtr<class USoundAttenuation> AttenuationSettings = nullptr;
Then it does not works in BeginPlay() (Audio is not a valid pointer)
The AttenuationSettings file appears to be fine (doesn’t look to be corrupt).
So it’s a big problem for me… I need the attenuation. And I need to spawn the audio as soon as possible like in BeginPlay().
Any help to solve this problem is welcome.
Thank you so much!!