Download

[Need help] Sound problem at runtime

Hello,

I’m currently using this function to play a sound :

UAudioComponent* AnAudioComponent;
USoundBase* ASound

AnAudioComponent = UGameplayStatics::PlaySoundAttached(ASound, GetRootComponent());

I notice this in the docs : “This is a fire and forget sound.” but I’d like to be able to change its volume in the tick function.
Currently with this function, it’s not possible. If anyone has a workaround for this, it would be much appreciated!

Cheers!

Fire and forget isn’t really accurate for PlaySoundAttached, I’m not sure why the function says that, bad copy and paste I suppose. PlaySoundAtLocation is absolutely fire and forget.

The AudioComponent pointer returned to you from the function can be used to manipulate the volume via SetVolumeMultiplier or AdjustVolume (depending on if you want instant or interpolated over time).

Thank you for the quick reply, I was trying to modify the volume multiplier like this :

AnAudioComponent.VolumeMultiplier = …;
//instead of
AnAudioComponent.SetVolumeMultiplier(…);

With the latest, it works perfect!