UAudioComponent->SetSound() crashing editor

The editor tells me “Access violation - code c0000005(first/second chance not available)”, but I’m not getting any errors in VS. It doesn’t matter if I use a USoundWave or USoundCue.

Header:

UAudioComponent* KickAudioComp;

Constructor:

static ConstructorHelpers::FObjectFinder<USoundWave>Kick(TEXT("SoundWave'/Game/Audio/Kick3.Kick3'"));

KickAudioComp->SetSound(Kick.Object);

Anyone? I can’t figure out if this is a bug or if I’m doing something wrong.

Hello,

Make sure you create component and attach it. Try this

KickAudioComp = ObjectInitializer.CreateDefaultSubobject<UAudioComponent>(this, TEXT("AudioTest"));
KickAudioComp->AttachParent = GetMesh();

Best regards,