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 Playlist with Song Name

Been playing around with Unreal Engine after some time away, and a lot of stuff has changed. I was looking at going after the following:

  • Player loads the main menu to the game, which would display all menu options [done]

  • Music playlist would start playing a random song (currently, I have this setup in a cue just picking a random song)

  • Would display a widget in the bottom right showing the name of the song.

Issues I'm having: It appears that the music is random based on each time you re-open the game, and it just keeps looping that one song. How would I go about getting a TRUE random. (Once a song is finished it cycles through the list again)

Next: To my understanding of how others have tried to achieve getting the song name, the simple way would just be to insert these as strings, attached to each file somehow, and it would fetch the song name string associated to that song. The question is, how?

I've thought about going at this with level blueprints, or just putting a sound cue in the position of where the player start is on the map. But for the music to display the actual title that I attach to the string, what would be the best way? I've thought about arrays, etc. But don't really have a solid direction to go in to where I can actually assign a string property to each song in the randomized list of the sound cue. Then I could just use get/set on that string as a variable.

Any help would be appreciated.

Product Version: UE 4.12
Tags:
more ▼

asked Jan 10 '17 at 02:56 PM in Blueprint Scripting

avatar image

IAMRichardT
3 1 3 5

avatar image Minus_Kelvin STAFF Jan 10 '17 at 07:31 PM

Just make a BP array with USoundBase as the type. Then add the sound waves directly (don't use a sound cue) either as a public variable (so you can reuse your BP script) or do it as a default array. Make a copy of this array when the script starts (OnBeginPlay) so you can reset back to the original list.

Then when you play a song, randomly pick from this list (random int range between 0 and the size of the list). Remove the chosen item from the copied list so you don't pick it again.Then play the audio with an audio component (spawn sound or add component to your BP actor). Then register a delegate function to be notified in BP when the song finishes.

Then when the song finishes do the above again until you don't have any more songs in your copied list. Then when your list is empty re-copy to it from your original list and start over.

avatar image Bushey Nov 20 '17 at 10:47 AM

I'm working on something similiar, how would I go about displaying the song name on the screen?

Many thanks,

P

(comments are locked)
10|2000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
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