Audio does not play on spawn

My ball actor has an UAudioComponent, which should play when the ball gets spawned. It also hasa particle system that should start playing at the same time.

void ABall::OnConstruction(const FTransform& Transform)
{
    Super::OnConstruction(Transform);
    this->ParticleSystem["P_BallIn"]->ActivateSystem();
    this->Audio["BallIn"]->Play();
}

The particle system starts playing just fine, however, the audio is not playing at all. This is peculiar, because the audio does play in other non-spawning methods just fine. That means that there’s nothing wrong with the audio file, and it does get loaded correctly in PostInitializeComponents. I tried Activate() instead of Play() as well, but that did not solve the problem.

I already tried that as well, no sound gets played. If I place it somewhere else, it works fine.

Ah, that did the trick. I expected it to work with this event as well. Feel free to add this as an answer so I can accept it :slight_smile:

Did you try play on BeginPlay()?

You can also use PlaySoundAtLocation() which does not require audio component

https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/AActor/PlaySoundAtLocation/index.html

Ok converted to answer then :slight_smile: