Announcement

Collapse
No announcement yet.

Audio Between Levels: Possible on Game Instance?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Audio Between Levels: Possible on Game Instance?

    Hello,

    Preface - I have used Unreal in the past, but I am extremely rusty as several new projects I am working on use it.

    I am currently implementing some audio for a game, and I am wondering what the best method to implement music between maps. In the past, it was suggested that I use a persistent level and level streaming to accomplish this; however, the current projects are not set up in this manner, and I fear the amount of work involved to convert them to the streamed levels.

    I had an idea about calling the audio from the GameInstance, as I believe this persists between levels. Has anyone gotten a system like this to work?

    #2
    Yeah, if you pass an audio component to the Game Instance it will persist between levels.
    Try my procedural music tools: Arthurs Audio BPs

    Comment


      #3
      Awesome, thanks for comment!

      Would you happen to be able to point me in the direction of an efficient way to do this? I am essentially having to relearn how to work in Unreal after so long. I'm assuming there is something regarding this function in the doc?

      Comment


        #4
        I will quote Dan, epic audio god:
        "You play music on an Audio Component, you pass the Audio Component Reference to something that persists between levels, like the Game Instance, the Game Instance passes the Audio Component back to the next level."

        So it's very doable in normal blueprints, either create your own gameinstance and hook it up to game, or for example cast to the pre-existing one through other BPs. Many ways to go about it.
        Last edited by ArthurBarthur; 05-13-2019, 05:57 AM.
        Try my procedural music tools: Arthurs Audio BPs

        Comment


          #5
          Got it. Thanks a lot!

          Comment


            #6
            i've tried it but the music stops as soon as i change maps. what could be the problem,

            i've created a custom event inside the game instance and hooked it to the (play sound 2d) and created a public boolean variable so i can cast the events once.
            here is what i have in games instance :

            Click image for larger version

Name:	20191103-22_08_23planeselect_.jpg
Views:	197
Size:	291.5 KB
ID:	1681904 and here i cast to the game instance from the level blueprint :Click image for larger version

Name:	20191103-22_13_37SKY_LEVEL_selection_--Level-Blueprint-Editor.jpg
Views:	183
Size:	272.8 KB
ID:	1681905


            i hope to hear from u soon, thanks
            Bayan Al-safadi
            Architect
            International Core Studios

            Comment


              #7
              Originally posted by ttm1st View Post
              custom event inside the game instance and hooked it to the (play sound 2d)
              'Play Sound 2d' is like a fire and forget thing. You need to add/spawn an audiocomponent(a sound), and ALSO promote that spawned sound/audiocomponent to a variable. Then it's this variable that gameInstance keeps track of.
              Try my procedural music tools: Arthurs Audio BPs

              Comment


                #8
                Hello,

                Thank you for this thread!

                I'm trying to use this method for a game.

                I've created an audio component on a dedicated blueprint named BP_Music_System, and I fire the component on event begin.

                But how to promote that as a variable and what type of variable would it be?

                Comment


                  #9
                  Originally posted by SuperApe33 View Post

                  But how to promote that as a variable and what type of variable would it be?
                  Variable would be type of itself, "audio component", and if it's in the bp as a component, it is already stored as a variable. To create more variables/references to it, plop it into the graph and drag out of the right side. On top of the big list that popups it should say "promote to new variable"! Would have to f.ex cast to game instance and have it store the variable at some point.
                  Try my procedural music tools: Arthurs Audio BPs

                  Comment


                    #10
                    Also trying to figure out how to do this - It seems fairly simple, but just can't work out how to do it ;_;

                    Anyone in the thread actually managed to get it going?

                    Comment

                    Working...
                    X