How to PlaySoundOnActor in 4.10?

You used to be able to say:

USoundCue* MySound = Sound;


Now, USoundCue doesn’t even exist. In 4.10, what method is used to call sound on actor?

You mean 4.1 or 4.10? those are two different versions

4.1.2, the latest version of unreal engine.

you mean 4.10 not for 4.1, 4.1 is old version it was first bigger update there currently 10 versions and you speaking about 10th one if you talking about latest. I will correct your quastion

I remeber one of play sound function been been depricated and i had warning to replace it with this one (for some reason can’t find it in API refrence so here you have paste from source code):

UAudioComponent* UGameplayStatics::SpawnSoundAttached(
class USoundBase* Sound, 
class USceneComponent* AttachToComponent, 
FName AttachPointName, 
FVector Location, 
FRotator Rotation, 
EAttachLocation::Type LocationType, 
bool bStopWhenAttachedToDestroyed, 
float VolumeMultiplier, 
float PitchMultiplier, 
float StartTime, 
class USoundAttenuation* AttenuationSettings, 
class USoundConcurrency* ConcurrencySettings

Only 2 first arguments is needed, if you dont know which component to use just do this Actor->GetRootComponent(). It’s a static function so you don’t need object just use UGameplayStatics::. Also note that it creates audio component on your actor which can be reused as it returns it. Generally you should play sounds from audio component in actor, aspecially if it’s same sound all the time.

I guess they removed old function now. Pro tip: if you update to new version you will get warnings during compilation if something is deprecated and will be soon removed, it also usally tells you what you need to so with old function (usally replace with new one), some of those can be simply updated by using project-wide “Find and Replace”, but some require to update each case of use (like this case, as you see it’s way different then it use to be). So update UE4 all the time (you can skip stable releases like x.x.1 etc.) and check those warnings on each update, it best way to always keep your code up to date.

Thank you very much :slight_smile:

Yes, we changed the BP static function names to better indicate the difference between the PlaySound* and the SpawnSound* functions. A PlaySound* call won’t create an audio component (which is a lot cheaper since scene components can get expensive in a big game) while a SpawnSound* will. If you are playing a one-shot sound that you don’t need to modify while it’s playing or if you don’t need it to really tightly update its position on a moving actor, then you should use PlaySound*.

So what is the correct replacement for the code below please?

USoundCue* MySound = Sound;

I’m still not sure how to replace those two lines. Could you please give an example how to replace

 USoundCue* MySound = Sound;

He is talking about this one, this one don’t create component:


To see all the API for audio in BP, check out GameplayStatics.h.

As I said, if you don’t need an audio component use the PlaySound* flavor of functions:

  • PlaySound2D()
  • PlaySoundAtLocation()

If you need an audio component, then use the SpawnSound*:

  • SpawnSound2D()
  • SpawnSoundAttached()
  • SpawnSoundAtLocation()

The USoundCue object shouldn’t have changed or disappeared. The object and the BP function are independent.

Unfortunately it looks like USoundCue actually has changed or disappeared from a C++ perspective (in 4.10.2):

Not sure what you’re trying to do here - USoundCue inherits from USoundBase, so you either want:

USoundBase* MySound;


USoundCue* MySound;

Depending on what type you specifically want to refer to.