Uncover the Simple Trick to KEEP MUSIC PLAYING Between Scenes!

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ก.ย. 2024
  • In this Unity Audio Manager tutorial we'll learn How to CONTINUE PLAYING MUSİC Between Multiple Scenes in Unity.
    You have background music in every scene, and the music returns to the beginning as the scene changes. ? You will learn the solution in this Unity Audio Management tutorial.
    Enjoy the video ☕
    ----------------------------
    🖐 Hi Game developer
    Welcome to Rehope Games I'm Murat
    I share unity tutorial videos on my channel. if you want to make a game with unity (especially 2d platformer game), the videos here will definitely interest you.
    ----------------------------
    #unitytutorials, #unity2d, #unity2dplatformer

ความคิดเห็น • 35

  • @Garfield_Minecraft
    @Garfield_Minecraft 5 หลายเดือนก่อน +8

    ok just remember to carry the speaker everywhere you go

  • @pedrokkj7304
    @pedrokkj7304 ปีที่แล้ว +4

    Hey, I love your tutorials on music and SFX.
    How would I change music when entering a new scene? Create an audio script for each scene?

    • @RehopeGames
      @RehopeGames  ปีที่แล้ว +4

      Hi,
      You can do this a few different ways.
      I think the simplest way;
      - You can create single Audio Manager ( carry it to all scenes with DontDestroyOnLoad method).
      - And You can access the Audio Manager from new Scene (from any Start function) and change the audio clip.
      Thanks for your feedback 🙏

    • @Satenc0
      @Satenc0 7 หลายเดือนก่อน

      @@RehopeGames Would be good if you can elaborate a little bit more on this, how could I select a different audio file from a method of AudioSource? Also how to get the current scene name or index and based on that select the AudioSource to play

  • @ChapCanai
    @ChapCanai ปีที่แล้ว +6

    I dont regret accidentally listening to the game music at 2x speed

  • @x_arnie
    @x_arnie 10 หลายเดือนก่อน +3

    Very nice! But i have a problem of the music playing multiple times if i go between main menu and guide menu of my game.

    • @RehopeGames
      @RehopeGames  10 หลายเดือนก่อน +1

      Hi, You should take a look at Singleton Pattern 👍
      Thanks 🙏

  • @programmingwithryan
    @programmingwithryan ปีที่แล้ว +3

    Hello Sir can you share this project i want to test this game very much. And I want to use this for my project.Tks

  • @boshhy
    @boshhy ปีที่แล้ว +1

    Thank you.

  • @dertobbe1176
    @dertobbe1176 11 หลายเดือนก่อน +1

    Huh, neat

  • @user-hx6ns1mo9b
    @user-hx6ns1mo9b 6 หลายเดือนก่อน

    Having an issue where the sound effects aren't playing if I open an older screen (like my main menu), the music works fine, but nothing is able to register the audiomanager or the script.

  • @IheartGames646
    @IheartGames646 ปีที่แล้ว +1

    I’m working on a project and I followed your tutorial. Everything works perfectly but the thing is I made a start screen that plays a certain music and when I transition to another scene that same music is still playing. I have assigned a new music to where my player is and I cannot hear that music because the music from the start screen is still playing, I also cannot hear my player jump or collect the coins. How would I fix

    • @RehopeGames
      @RehopeGames  ปีที่แล้ว +1

      I think this video can give an idea on this topic.
      th-cam.com/video/N8whM1GjH4w/w-d-xo.html
      Thank you 😊

  • @Narwing
    @Narwing ปีที่แล้ว +2

    I love you

  • @Broockle
    @Broockle 11 หลายเดือนก่อน

    "public static AudioManager instance;"
    this line is giving me trouble. I never used 'static' before.
    How did you make yours work?

    • @RehopeGames
      @RehopeGames  10 หลายเดือนก่อน

      You should learn Singleton pattern 👌

  • @yonezu5058
    @yonezu5058 4 หลายเดือนก่อน

    Can it use with a multiplayer game?

  • @komradwide4660
    @komradwide4660 ปีที่แล้ว +1

    But how would you make it so that specific scenes wont have the audio play?

    • @RehopeGames
      @RehopeGames  ปีที่แล้ว

      If you remove the Audio Listener component from the Main Camera in the scene where you don't want the sound to play, you won't hear any sound in that scene. This is the simplest method.
      But if it were me, I would write a small algorithm instead. 😎

    • @Stigma536
      @Stigma536 ปีที่แล้ว

      @@RehopeGames How do I make it so that in the Start/Title screen one audio plays, then in the options menu a different one plays, then in the main game a different one plays?

  • @pandlyn
    @pandlyn ปีที่แล้ว +1

    how to change the melody in certain scenes?

    • @RehopeGames
      @RehopeGames  ปีที่แล้ว

      Hi, maybe this video can give an idea for that th-cam.com/video/N8whM1GjH4w/w-d-xo.html

    • @pandlyn
      @pandlyn ปีที่แล้ว

      @@RehopeGames i will try, thanks)

  • @aboodabusaif648
    @aboodabusaif648 7 หลายเดือนก่อน

    bro my SFXSource give me null reference exception IDK why :(

  • @burgi2980
    @burgi2980 10 หลายเดือนก่อน

    I just want the music to run if the same scene restarts and not if I for example go back to the menu scene. any help?

    • @RehopeGames
      @RehopeGames  10 หลายเดือนก่อน

      Hello , I understand your request. This code will give an idea for you.
      using UnityEngine;
      using UnityEngine.SceneManagement;
      public class MusicPlayer : MonoBehaviour
      {
      private static MusicPlayer instance = null;
      public AudioClip menuMusic; // Audio clip for menu music
      public AudioClip gameMusic; // Audio clip for game music
      private AudioSource audioSource;
      public static MusicPlayer Instance
      {
      get { return instance; }
      }
      void Awake()
      {
      if (instance != null && instance != this)
      {
      Destroy(this.gameObject);
      return;
      }
      else
      {
      instance = this;
      }
      DontDestroyOnLoad(this.gameObject);
      audioSource = GetComponent();
      SceneManager.sceneLoaded += OnSceneLoaded; // Subscribe to scene loaded event
      }
      void OnSceneLoaded(Scene scene, LoadSceneMode mode)
      {
      // Change the music when returning to the menu scene
      if (scene.name == "MenuScene")
      {
      audioSource.clip = menuMusic;
      audioSource.Play();
      }
      // Continue playing game music when switching to the game scene
      // only if it's not already playing the game music (e.g., after a restart within the game scene)
      else if (scene.name == "GameScene" && audioSource.clip != gameMusic)
      {
      audioSource.clip = gameMusic;
      audioSource.Play();
      }
      }
      void OnDestroy()
      {
      SceneManager.sceneLoaded -= OnSceneLoaded; // Unsubscribe from the event to prevent memory leaks
      }
      }

  • @l1ax175
    @l1ax175 ปีที่แล้ว +1

    THANKS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • @FaKz92
    @FaKz92 6 หลายเดือนก่อน

    your tutorials are good, but if the watcher did not saw the previous ones he's fucked up, and you never are reffering to the previous videos.
    This is a big minus in all your videos.

  • @kursatkilitci7770
    @kursatkilitci7770 ปีที่แล้ว +1

    Thx bro

    • @RehopeGames
      @RehopeGames  ปีที่แล้ว

      biz teşekkür ederiz 😊