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"

How to play multiple sounds at once from one Audio Component?

Hello!

I have modified the First person controller class to have a jump and sprint function, and it is working well in regards to functionality.

When the player lands there is a sound effect played, likewise when the player begins to sprint.

The issue is whenever the landing sound is played, it is stopped halfway through and the sprint sound begins to play.

How do I allow the landing sound to finish playing while the sprint sound begins to play?

Is this even an option with the audio component attached to the player? How do I achieve this?

EDIT: I forgot the code like a goober

     if (SprintSound != NULL && bHasPlayedSprintSound == false)
     {
         bHasPlayedSprintSound = true;
         AudioComponent->SetSound(SprintSound);
         AudioComponent->Play();
     }

I also play my other sounds using the SetSound() and Play() functions on the component. Thank you!

Product Version: UE 4.12
Tags:
more ▼

asked Aug 30 '16 at 11:46 PM in C++ Programming

avatar image

JasonWarrenCook
5 3 3 7

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

1 answer: sort voted first

Just make 2 audio components, and assign sprint to one and land to the other. Attach both audio components to your actor.

more ▼

answered Aug 31 '16 at 12:54 AM

avatar image

sranck
306 6 6 18

avatar image JasonWarrenCook Aug 31 '16 at 01:22 AM

Sounds good will accept this as soon as I try it. Is this okay to do performance wise?

avatar image sranck Aug 31 '16 at 01:24 AM

Yes, absolutely fine from a performance perspective.

avatar image JasonWarrenCook Aug 31 '16 at 01:48 AM

It's working great, thank you for helping!

avatar image Minus_Kelvin STAFF Aug 31 '16 at 06:52 PM

Think of audio components as a handle to a single playing sound. It allows you to change a sound's position, it's volume, it's pitch, etc, from BP.

In truth it's actually a handle to an "active sound", where an active sound may have multiple sound wave instances if the active sound has a USoundBase type that is a sound cue, and that sound cue is playing multiple sounds at once (through a mixer node, etc).

But the point is generally true and you should always think of audio components as a handle to a single sound.

(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