playMaker

Author Topic: Pause Resume Music  (Read 2100 times)

missakmissak

  • Playmaker Newbie
  • *
  • Posts: 12
Pause Resume Music
« on: November 30, 2015, 05:24:49 PM »
Hello,
I have a music that starts from the first scene and I made it don't destroy on load so that it continues to play while I load other scenes. The problem is I have icons in other scenes that will let the player to turn off(pause) and on(resume) the music. I am trying to do this way.
1.find the game object(that has the audio source) and store in a gameobject variable.
2.audio pause and select the variable.

This is not working. Is there any other way?

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: Pause Resume Music
« Reply #1 on: November 30, 2015, 07:00:22 PM »
You could have the game object that plays the music use "get owner" and store itself as a global game object variable then send the pause command to that-
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

missakmissak

  • Playmaker Newbie
  • *
  • Posts: 12
Re: Pause Resume Music
« Reply #2 on: December 01, 2015, 03:03:04 PM »
How can I send the command to that? They are in different scenes. The playmaker of one scene cannot see the global variables of other scenes. Maybe I understood differently.

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: Pause Resume Music
« Reply #3 on: December 01, 2015, 06:55:24 PM »
What I was thinking- was keep using "Don't destroy on load" (there's also a Singleton action on ecosystem that might be useful) And just use a global var instead of searching for the game object- so have it declare itself using "get owner"
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

gregacuna

  • Full Member
  • ***
  • Posts: 143
Re: Pause Resume Music
« Reply #4 on: June 06, 2017, 12:10:52 AM »
Just in case someone comes across this I was working on it and came across the solution after experimenting.

We start audio play on an empty game object in the first scene, Set Game Object to a global and apply a Do Not Destroy. Then in settings we use a Get Component to get the Audio Component on that game object using the Global variable.

Tried using Pause Music...but it is easier to simply use Mute since it can be toggled.

Hope that helps someone someday. :)