Soundcue not playing?

No sound happens when I fire? I also tried to apply a sound for my health pickup and ammo pickup but can’t seem to get them to work either. What I am doing wrong?

My .cpp file

AWeapon::AWeapon(const FObjectInitializer& projectileVar)
             : Super(projectileVar)
             AudioComp = CreateDefaultSubobject<UAudioComponent>(TEXT("AudioComp"));
             AudioComp->AttachParent = RootComponent;
             AudioComp->bAutoActivate = false; 
             AudioComp->bAutoDestroy = false;
     void AWeapon::Fire()
             if (LazerGun)

.h file

 UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Sound")
         UAudioComponent* AudioComp; 
  UPROPERTY(EditDefaultsOnly, Category = "Sound")
         USoundCue* LazerGun;

Have you tried this?:

  • UGameplayStatics::PlaySound2D(UObject* WorldContextObject, class USoundBase* Sound, float VolumeMultiplier, float PitchMultiplier, float StartTime)

Don’t know how to set that up so no. If you would like to show, I may try it. But would like to get my way to work.

I just showed you exactly how to set it up… how much experience do you have in C++ ?

Not a great deal, still learning. And haven’t really used UGameplayStatics much.

Then start learning the way everyone else is doing it. Obviously there are multiple ways of doing it, but my solution is easiest (well, that’s subjective also I suppose).

  • If I have answered your question, please upvote and mark it answered to close this report.
  • Good luck!

Not really answered but thanks.

Between those two docs, you should be able to do anything with sounds. Good luck!

Make sure to set your sound as LazerGun in your weapon blueprint… facepalm

… heh, good job!