Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Can not play a disabled audio source, but the source is definitely not disabled!

$
0
0
This is the error message I'm getting:

Can not play a disabled audio source
UnityEngine.AudioSource:Play()
SoundManager:BallHitsBlockSound() (at Assets/Scripts/SoundManager.cs:20)
Block:OnCollisionEnter2D(Collision2D) (at Assets/Scripts/Block.cs:11)

As you can see in the Inspector screenshot below, the SoundManager object is enabled, and the AudioSource component is enabled. Any idea what could be causing this? Based on another answer elsewhere I have checked to be sure that this script is only on one object.

![alt text][1]

I don't believe the problem is in code, but just in case I have included the script in question:

using System.Collections; using System.Collections.Generic; using UnityEngine; public class SoundManager : MonoBehaviour { AudioSource audioSource; public AudioClip blockHit; public AudioClip racketHit; private void Start() { print("I'm attached to " + name); audioSource = GetComponent(); } public void BallHitsBlockSound() { audioSource.clip = blockHit; audioSource.Play(); } public void BallHitsRacket() { audioSource.clip = racketHit; audioSource.Play(); } }

Thank you for any help you can give! :) [1]: /storage/temp/136781-capture.png

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>