# Play Sound Cue like in the Shooter game example

**URL:** <https://forums.unrealengine.com/t/play-sound-cue-like-in-the-shooter-game-example/438657>\
**Category:** Audio\
**Tags:** c-build-fail, unreal-engine, question, CPP\
**Created:** [December 1, 2018, 10:22am UTC](https://forums.unrealengine.com/t/play-sound-cue-like-in-the-shooter-game-example/438657 "2018-12-01T10:22:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bitwaker](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Bitwaker](https://forums.unrealengine.com/u/Bitwaker)\
**Post date:** [December 1, 2018, 10:22am UTC](https://forums.unrealengine.com/t/play-sound-cue-like-in-the-shooter-game-example/438657/1 "2018-12-01T10:22:45Z")

</div>

Checking the Epic Shooter source I can clearly see that they are using **SpawnSoundAttached** to play a weapon sound.

```
UAudioComponent* AShooterWeapon::PlayWeaponSound(USoundCue* Sound)
{
	UAudioComponent* AC = NULL;
	if (Sound && MyPawn)
	{
		AC = UGameplayStatics::SpawnSoundAttached(Sound, MyPawn->GetRootComponent());
	}

	return AC;
}

```

I’m trying to play a sound in a very similar way, I do not need to keep track of the AudioComponent, but the rest of the code is exactly the same but I’m receiving an error saying that the two params that I’m passing cannnot be converted into the needed params.

```
void AWeaponBase::PlayWeaponSound()
{
     UGameplayStatics::SpawnSoundAttached(FireSound, RootComponent);
}

```

FireSound is SoundCue\* exactly as for the Epic example. Could you kindly help me understsand what Iìm doing wrong?

---

<div class="post-metadata">

**Author:** ![NoCodeBugsFree](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NoCodeBugsFree](https://forums.unrealengine.com/u/NoCodeBugsFree)\
**Post date:** [December 1, 2018, 11:39am UTC](https://forums.unrealengine.com/t/play-sound-cue-like-in-the-shooter-game-example/438657/2 "2018-12-01T11:39:41Z")

</div>

/\*\* .h _/  
/_\* sound to play when … _/  
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = “Config”, meta = (AllowPrivateAccess = “true”))  
class USoundBase_ FireSound;

```
/**.cpp */
/** */
#include "Kismet/GameplayStatics.h"
UGameplayStatics::PlaySoundAtLocation(this, FireSound, GetActorLocation());
UGameplayStatics::PlaySound2D(this, FireSound);
```

---

<div class="post-metadata">

**Author:** ![NoCodeBugsFree](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NoCodeBugsFree](https://forums.unrealengine.com/u/NoCodeBugsFree)\
**Post date:** [December 1, 2018, 11:41am UTC](https://forums.unrealengine.com/t/play-sound-cue-like-in-the-shooter-game-example/438657/3 "2018-12-01T11:41:22Z")

</div>

try this way. don’t forget to set FireSound in BP

---

<div class="post-metadata">

**Author:** ![Bitwaker](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Bitwaker](https://forums.unrealengine.com/u/Bitwaker)\
**Post date:** [December 1, 2018, 12:19pm UTC](https://forums.unrealengine.com/t/play-sound-cue-like-in-the-shooter-game-example/438657/4 "2018-12-01T12:19:15Z")

</div>

Actually it seems the problem was that I forgot to include “Sound/SoundCue.h”

---

<div class="post-metadata">

**Author:** ![Bitwaker](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Bitwaker](https://forums.unrealengine.com/u/Bitwaker)\
**Post date:** [December 1, 2018, 12:20pm UTC](https://forums.unrealengine.com/t/play-sound-cue-like-in-the-shooter-game-example/438657/5 "2018-12-01T12:20:22Z")

</div>

Stupid question sorry.  
I forgot to include “Sound/SoundCue.h”
