x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Audio que is not playing on Preview Client, but is on Preview Server

Ive been working from the tutorial https://wiki.unrealengine.com/Survival_Sample_Game:_Section_1.

In there, there is a UsableItem > PickupItem > ConsumableItem.

The "PickupItem" class has logic to play a sound que at location which works like so:

 UGameplayStatics::PlaySoundAtLocation(this, PickupSound, GetActorLocation());


It works, but when I have multiplayer viewports open I notice the sound only plays on the "Preview Server" viewport, It does not play the sound inside the "Preview Client". I can also pick up the item with the Client player but I can only hear the sound playing in the "Preview Server" viewport.

As a workaround Ive tried placing the, "PickupSound" sound que inside an AudioComponent. I Initialize the AudioComponent, and tried to replace the "PlaySoundAtLocation" in the OnUsed function like so:

     //UGameplayStatics::PlaySoundAtLocation(this, PickupSound, GetActorLocation());
     if (PickupSound)
         {
             AudioComp->SetSound(PickupSound);
             AudioComp->Play();
         }

But this is even worse, as nothing plays when trying to activate the sound this way, not in Client nor Server viewports.

For settings Ive checked the box in Editor Preferences > Play > Create Audio Device for Every Player

Im not sure what to do next aside from rebuilding everything over again, but I cannot see anything in the code that I would do differently especially in those few files that create the item.

Anyone have an idea of what might be going on and what I can do?

Product Version: UE 4.8
Tags:
more ▼

asked Jul 29 '15 at 05:22 PM in C++ Programming

avatar image

berserkturtle
1 1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hey, so how are you calling PlaySoundAtLocation? From C++? I recommend calling the function from blueprints -- I just ran a test with a simple setup in the level blueprint as follows:

alt text

The sound played properly in all the multiple PIE sessions I launched (PIE => play in editor) which simulates the multiple clients. The thing that is tricky is the static function in C++ actually takes a WorldContextObject as its first argument:

 void UGameplayStatics::PlaySoundAtLocation(UObject* WorldContextObject, class USoundBase* Sound, FVector Location, FRotator Rotation, float VolumeMultiplier, float PitchMultiplier, float StartTime, class USoundAttenuation* AttenuationSettings)

In blueprints, this is automatically passed to the blueprint function and will play the sound in the appropriate viewport/world (and thus be heard across the multiple PIE sessions). If you call the function manually in C++, you need to make sure you pass in the appropriate WorldContextObject. My guess is that the "this" pointer in your code is the world context for only one of the PIE viewports. I looked through the tutorial briefly and didn't see how they're setting up the call from C++ and what "this" is.

Another thing that could be happening is that the "multiple audio device" feature automatically mutes the PIE windows that aren't in-focus (i.e. the currently controlled PIE viewport). As you flip between the viewports, it will play audio from that viewport (and mute the old viewports). The idea is that you really only want to hear one audio viewport at a time (otherwise it'd be cacophony). You can bypass this by specifically soloing one viewport so you can hear audio from that viewport while you control another.

more ▼

answered Jul 29 '15 at 08:07 PM

avatar image

Minus_Kelvin STAFF
922 23 5 31

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question