How to Play or Stop Music Through Scenes in Unity

Поделиться
HTML-код
  • Опубликовано: 12 янв 2025

Комментарии • 37

  • @Dorbellprod
    @Dorbellprod 2 года назад +7

    Now I can hear Bad Piggies Theme in my game forever
    Also, suggestion, perhaps BGmusic should store a reference to its AudioSource so you won't have to call GetComponent a lot 😳

  • @1ericfeu
    @1ericfeu Год назад +4

    This is the most straightfoward and informational and fast pace tutorial i have ever seen, underated as heck this guy

  • @gamesbyspinola
    @gamesbyspinola 2 года назад +7

    One thing I didn´t notice and might be important to notice is that the Audio GameObject with BGmusic script can´t be a child object I had my Audio as a child object and it was not working! Great video it´s simple and effective way to persist and pause audio trought the scenes.

  • @potatomend4958
    @potatomend4958 2 года назад

    Oh my God thank you man, I was just about to give up on having music in the backgroud, thank you so much.

  • @edwardnathaniel3108
    @edwardnathaniel3108 2 года назад +2

    simple but effective tutorial dude

  • @DevNoob
    @DevNoob 2 года назад +4

    Nice! Gotta use this more :) Very straightforward to keep music through scenes it seems. Great explanation

    • @BillyMan
      @BillyMan  2 года назад

      Thank you, I'm glad you liked it :D

  • @Riv3rz
    @Riv3rz Год назад

    Underrated.. seriously also nice french skills i really love the word shit

  • @hk-0148
    @hk-0148 Год назад

    Good tutorial! I only used the first script for my prototype, and it worked perfectly! Thank you!

  • @nikijs877
    @nikijs877 2 года назад

    This is the best tutorial ever! Good job!

  • @Baylan321
    @Baylan321 Год назад

    Quick and great tutorial! Thanks!

  • @infinity1285
    @infinity1285 2 года назад +2

    where do we apply the second script? i have my audio source but it doesnt let me apply swap scene

  • @MrElectorium
    @MrElectorium 2 года назад +4

    your code doesnt work if you try to go back, like scene one is the menu with different music, and scene 2 goes through scene 10 with the repeating music, but if i go to scene 1 and back to scene 2-10 the music stops
    Edit: i realize why its doing this, its because the game object is destroyed so when you load the scene again, theres no music playing because there's no music to be played. but i still dont know how to fix it

    • @omarcano6195
      @omarcano6195 Год назад

      Have you found a solution?

    • @MrElectorium
      @MrElectorium Год назад

      @@omarcano6195 lookup catto devs video "how to seamlessly play audio between multiple scenes"

    • @dachigobejishvili853
      @dachigobejishvili853 10 месяцев назад

      couldn't you fix this by deleting the "Destroy(gamobject);" line? you wouldn't need it for anything else anyways right?@@omarcano6195

  • @alejandro60251
    @alejandro60251 Год назад

    Hello, this was a brilliant tutorial. I was wondering why the music I have in a scene also stops playing despite not having this script? I wish you could help me

  • @troutki
    @troutki 2 года назад

    I am having trouble getting it to stop on a certain scene. (I am new to coding so I am kinda dumb) When I put the second code into my switch scene thing it doesn't stop, I put the right name and there were no errors but it wouldn't stop. If it helps I use buttons as the menu to diffrent scenes and I tried to put the code there but it wouldn't work.

  • @playanoapps
    @playanoapps 2 года назад

    great tut!

  • @melsannit
    @melsannit 2 года назад

    why my music won't play again when I return from the pause scene?
    where should I put the resume code so my music can play again

  • @arnauz11
    @arnauz11 2 года назад +1

    i have a problem.
    in first time works, but if i'm in scene 1 with music (A) pass to scene 2 with the same music, pass to scene 3 and i stop the music A because i want so hear music (B). When i return to scene 1, music (A) doesn't sound

    • @BillyMan
      @BillyMan  2 года назад +1

      hmm maybe you should put music B on a separate gameObject because that script checks whether there is already the same game object in the scene and then deletes it. Or you forgot to make the music continue when it reaches scene 1

    • @arnauz11
      @arnauz11 2 года назад

      @@BillyMan in scene 3 i have other Game object. I think that t'he probleme is when the music A stops in scene 3, when i retur to scene 1, continues in stop.
      What do you do?

    • @BillyMan
      @BillyMan  2 года назад

      @@arnauz11 maybe you can check if you're in scene 1 and use the play function like in the video to resume the music

    • @arnauz11
      @arnauz11 2 года назад

      @@BillyMan you mean that when i in scene 1 music A starts? I tried this, but i don't want that when i am on scene 2 Andreu change to scene 1 t'he music reload.
      But if is the only way...

    • @BillyMan
      @BillyMan  2 года назад

      @@arnauz11 you can just check if u are in scene 1 then continue the music, if u are in scene 2 then stop, it would work just fine

  • @DevonLea-j3v
    @DevonLea-j3v Год назад

    thanks man

  • @azzamrashid3726
    @azzamrashid3726 Год назад

    seriusly easy... thanks

  • @iteky1
    @iteky1 2 года назад

    thank you

  • @CarrotmanGames
    @CarrotmanGames 8 месяцев назад

    THX BRO HAHAAHAH YOU A LEGEND :D

  • @tibortorok9498
    @tibortorok9498 2 года назад

    nice

  • @lucutes2936
    @lucutes2936 Год назад

    thxxx

  • @salmadiaaelabsi
    @salmadiaaelabsi Год назад +1

    Where do I assign the second script??