Using SoundCue in actor class?

anonymous_user_bf5bfa7d
Sun, 19 Jun 2016 16:51:53 +0000
C++

I would like to access a SoundCue in one of my actor classes. I have an Actor class which contains a UAudioComponent member. The AudioComponent member is assigned a SoundCue class using AudioComponent::SetSound(). I set which SoundCue to use from the UE4 editor. THe AudioComponent member is then exposed through a blueprint method. I call Play() on it from my Blueprint. Only problem is I get no sound. Maybe it’s my BluePrint? Or is this doomed to fail from the onset?!

My Actor header contains the following:

UPROPERTY(EditAnywhere, Category = "Sound")
USoundCue* SoundCue;

UPROPERTY()
UAudioComponent* audioComponent;

UFUNCTION(BlueprintCallable, Category = "Sound")
UAudioComponent* getAudioComponent()
{
	audioComponent->Sound = SoundCue;
	return audioComponent;
}

I’ve checked the validity of the AudioComponent, and the SoundCue, and they are both valid. Any ideas?

4 posts - 1 participant