How would I play a soundcue asset that is referenced in a BP in C++?
UGameplayStatics::PlaySoundAttached(USoundBase*, USceneComponent*) seems like one possible solution. However, I’m not sure how to get the second argument, the USceneComponent, for the pawn I’m spawning.
Any help is appreciated.
Thank you.
EDIT [2015-10-18]:
It appears the following works:
const FStringAssetReference& AssetRef = pawn->sound.ToStringReference();
pawn->sound = Cast<USoundCue>(gameInstance->AssetLoader.SynchronousLoad(AssetRef));
if (pawn->sound.IsValid())
UGameplayStatics::PlaySoundAttached(pawn->sound.Get(), pawn->GetRootComponent());