Can't use PlaySoundAtLocation()

I included GameplayStatics.h, tried some variations, but the compiler keeps telling me that the function has no overrides for my set of arguments. I found this video and copied the code at 3:08, but nothing worked.
My cpp:

#include "Kismet/GameplayStatics.h"

...

void AMyActor::MakeSound() {
	bool bDoOnce = true;
	bool bHit = UKismetSystemLibrary::SphereTraceSingleForObjects(this, ... );
	if (bHit && bDoOnce) {
		bDoOnce = false;
		UGameplayStatics::PlaySoundAtLocation(GetWorld(), Sound, GetActorLocation(), 1.0f, 1.0f, 0.0f);
	}
}

What is Sound, is that a USoundCue ? if yes you should include its header, try putting nullptr instead of Sound and see if it compiles, if it does that means you need the header of whatever Sound variable type is.

1 Like