1. TY for a great tutorial...however 2. Help! I am adding the "AudioManager. instance. EatSFX() ;" Like this, to my game object (Crystal) script, and I get the error below (mine is a crystal sound): using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; public class Crystal : MonoBehaviour { private void OnTriggerEnter(Collider other) { AudioManager.instance.CrystalSFX; PlayerInventory playerInventory = other.GetComponent(); if (playerInventory != null) { playerInventory.CrystalCollected(); gameObject.SetActive(false); } } } The error I get (no matter where I call AudioManager.instance) is: Assets/Scripts/Crystal.cs(15,9): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement My AudioManager Script is: using System.Collections.Generic; using UnityEngine; using UnityEngine.Audio; public class AudioManager : MonoBehaviour { public static AudioManager instance; [SerializeField] AudioMixer mixer; [SerializeField] AudioSource crystalSource; [SerializeField] List crystalClips = new List(); void Awake() { if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); } else Destroy(gameObject); } public void CrystalSFX() { AudioClip clip = crystalClips[Random.Range(0, crystalClips.Count)]; crystalSource.PlayOneShot(clip); } } I loaded the 3 sounds in the AudioManager fields (inspector) and have my crystal sound on the CrystalSource game object audio source. What am I missing??
Thank you for the turorial! Quick question though, you showed how to set the Mixer using the slider values. How do you reverse that though, setting the slider values using the values from the Mixer? I'm asking cause I've had the sound settings in a separate option menu but whenever i open the sound option it doesn't update the sliders accordingly to the Mixer.
Great video, it helped me a lot.
I love this channel and it always helps out a lot (:
Appreciate the love
@Kap Koder can you do a video on something 3D I am new to coding and I really love coding games. Keep up the great work!
@@LumpyCustard521 like what?
@Kap Koder maybe something like movement or just learning stuff like vectors and wall running love the content (:
Yeah this channel is so helpful
thanks
Finally!
1. TY for a great tutorial...however 2. Help! I am adding the "AudioManager. instance. EatSFX() ;" Like this, to my game object (Crystal) script, and I get the error below (mine is a crystal sound):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class Crystal : MonoBehaviour
{
private void OnTriggerEnter(Collider other)
{
AudioManager.instance.CrystalSFX;
PlayerInventory playerInventory = other.GetComponent();
if (playerInventory != null)
{
playerInventory.CrystalCollected();
gameObject.SetActive(false);
}
}
}
The error I get (no matter where I call AudioManager.instance) is: Assets/Scripts/Crystal.cs(15,9): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
My AudioManager Script is:
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
public class AudioManager : MonoBehaviour
{
public static AudioManager instance;
[SerializeField] AudioMixer mixer;
[SerializeField] AudioSource crystalSource;
[SerializeField] List crystalClips = new List();
void Awake()
{
if (instance == null)
{
instance = this;
DontDestroyOnLoad(gameObject);
}
else
Destroy(gameObject);
}
public void CrystalSFX()
{
AudioClip clip = crystalClips[Random.Range(0, crystalClips.Count)];
crystalSource.PlayOneShot(clip);
}
}
I loaded the 3 sounds in the AudioManager fields (inspector) and have my crystal sound on the CrystalSource game object audio source.
What am I missing??
Thank you for the turorial!
Quick question though, you showed how to set the Mixer using the slider values. How do you reverse that though, setting the slider values using the values from the Mixer?
I'm asking cause I've had the sound settings in a separate option menu but whenever i open the sound option it doesn't update the sliders accordingly to the Mixer.
Well we already have the mixers channels variables so you can set the sliders value to the mixers value
I would love to learn more about Audio Mixers.
That's an amazing idea! I'm going to make a video about it
@@kapkoder4009 Thank you! ;)