Hello guys, I’m very new to Unity, been doing the Scavengers tutorial (2D Roguelike) from the learning section.
I’ve reached the 13 out of 14 video, just adding the sound
I’m doing exactly as they do it in there, but it does not work.
I’ve been typing the exact same code, and did the exact same SoundManager game object, and it just doesn’t work.
I’m currently half way of the video tutorial to add the sound, but the background music should be on by now.
here is the code of my SoundManager
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SoundManager : MonoBehaviour {
public AudioSource efxSource;
public AudioSource musicSource;
public static SoundManager instance = null;
public float lowPitchRange = .95f;
public float highPitchRange = 1.05f;
void Awake ()
{
if (instance = null)
instance = this;
else if (instance != this)
Destroy(gameObject);
DontDestroyOnLoad(gameObject);
}
public void PlaySingle(AudioClip clip)
{
efxSource.clip = clip;
efxSource.Play();
}
public void RandomizeSfx(params AudioClip [] clips)
{
int randomIndex = Random.Range(0, clips.Length);
float randomPitch = Random.Range(lowPitchRange, highPitchRange);
efxSource.pitch = randomPitch;
efxSource.clip = clips[randomIndex];
efxSource.Play();
}
}
Don’t have that.
I’m at the same stage as the tutorial, and when he launch the game, the sound works.
the SoundManager is the only new thing that I added
but if in the tutorial video it works for him, then it should work for me too.
I’ve put the Audio Source in the SoundManager, and checked the “Loop” same as he did.
here is the tutorial video, im at 6:13, this is where he launches the game, and the background music works
What you have so far should work… you’ve got your sound manager in the scene… your sound manager has an audio source on it with a clip attached… it’s set to play on awake. Weird.
Open up the audio right in Unity and play it. You can click on the audio file in Unity’s project explorer, and there should be a play button or something in the preview. Make sure you’re hearing sounds. Maybe your PC’s sound isn’t working right…??
Since you are on windows, you should have a sound icon in your system tray (I see it in your screenshot, so it’s there). When you play the game, click on that icon and see if sound is playing there. If you don’t see anything there, check the mixer to make sure the volume on the Unity player isn’t muted/turned down.