Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Lamb on May 25, 2016, 09:17:44 PM

Title: Music change, Audio Play causing multiples
Post by: Lamb on May 25, 2016, 09:17:44 PM
I'm setting up a music change system.
I want a track to play between scenes but then change to a different track on a couple of scenes.

I have an object that sets audio, compares a float, leads to states using play audio, then a stop audio upon float changed, compare float again, change track etc

I can get it all to work but when I enter a previous scene that had a different track that had played before, it sounds like it's adding another instance of the song playing. So switching between two scenes with different tracks led to really distorted sounding audio of what seemed like layers and layers of the same song.

I was trying to put together another approach where both play from the start and a float compare sets the volume from 0 to 1 depending on the scene but I couldn't get sound to happen that way.

Anyone having a similar issue or know a more elegant way to accomplish this?
Title: Re: Music change, Audio Play causing multiples
Post by: jeanfabre on May 26, 2016, 03:31:48 AM
Hi,

 If you have one manager for this audio system, make sure you deal with it when loading scenes.

use "dontdestroyonload" so that you keep the audio manager from scenes to scenes without loosing your current datat

use "Singleton" approach so that when you load a scene with the manager, it checks that it exists already and if it does only keep one instance ( the current).


http://hutonggames.com/playmakerforum/index.php?topic=12092.msg59859#msg59859

Bye,

 Jean
Title: Re: Music change, Audio Play causing multiples
Post by: Lamb on May 26, 2016, 03:05:45 PM
I've been reading a little about singleton but I'm also not a coder/just using Playmaker.

Are there singleton actions in playmaker I can get a hold of or do I need to do it all with a variable system or code only?
Title: Re: Music change, Audio Play causing multiples
Post by: Lamb on May 26, 2016, 08:14:33 PM
I tried having the music manager spawn in a scene that is never repeated to try and find a work around but it seems to me like it's using the Audio Play function [even after stopping audio] causing multiple instances of the song to play.

I dug around more and it seemed like there was a Singleton action set for PlayMaker posted in the past but I haven't been able to locate that.
Title: Re: Music change, Audio Play causing multiples
Post by: jeanfabre on June 08, 2016, 04:47:17 AM
Hi,

 Yeah, it's on the Ecosystem, search for "singleton".

Bye,

 Jean