#AudioSource stop

1 messages · Page 1 of 1 (latest)

unkempt delta
shadow kettle
#

h

strange summit
#

h

unkempt delta
#

well I'm not sure what the issue is, but have you considered making the AudioManager script a public static variable, so you could just do AudioManager.Stop("Theme");

#

Maybe how you're finding the AudioManager has to do it with 🤷‍♂️

shadow kettle
#

idek it can find and play the playerdeath sound but it says Assets\Scripts\playerCollision.cs(16,46): error CS1061: 'AudioManager' does not contain a definition for 'Stop' and no accessible extension method 'Stop' accepting a first argument of type 'AudioManager' could be found (are you missing a using directive or an assembly reference?)

unkempt delta
#

AudioManager is a script right?

shadow kettle
#

yeah

#

and an object

unkempt delta
#

does it have a public function called Play(), and Stop()?

shadow kettle
#

it has play, idk about stop

#

apparently stop is supposed to be built in

unkempt delta
#

you're trying to call a method in your AudioManager script called Stop(). If you didn't make one you get this error

#

You've probably confused it with AudioSource.Stop()

shadow kettle
#

ah yeah

#

lemme try defining a stop

#

yoo it works

#

ty

unkempt delta
#

however, what I was talking about earlier, is doing this:

In your AudioManager script, put a line at the top that says public static AudioManager instance;
then in Awake(), instance = this

shadow kettle
#

i was getting confused with audiosource yeah

unkempt delta
#

(I'm talking about how you can reference scripts without having to do FindObjectOfType<AudioManager>())

shadow kettle
#

yeah

unkempt delta
#

Then from any script in your game you can reference the AudioManager by doing AudioManager.instance.Stop()

#

does that make sense?

shadow kettle
#

yeah

#

so i just define a public audiomanager instead of having to find one?

#

then easily ref it

unkempt delta
#

yeah, a public static AudioManager is a variable that's accessible from all of your scripts

#

and static means there can only be one

shadow kettle
#

i see

#

ty :)