Can not play a disabled audio source

Linus K 21 Reputation points
2022-08-21T12:06:15.703+00:00

pls help me
Erorr:Can not play a disabled audio source
UnityEngine.AudioSource:Play ()
CoinController:OnTriggerEnter2D (UnityEngine.Collider2D) (at Assets/Scripts/CoinController.cs:11)

Code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CoinController : MonoBehaviour
{
public AudioSource coinAudioSource;

private void OnTriggerEnter2D(Collider2D collider2D)  
{  
    coinAudioSource.Play();  
    Destroy(gameObject);  
}  

}

Developer technologies | C#
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.