I have already programmed my coin to be a coin but when i went to program its sound effects i had a little issue with it. I wanted when i hit my coin to play this sound effect but i get an error can anybody help me please. Here is my script and my errors:
[/ using UnityEngine;
using System.Collections;
public class PlayerCoinSFX : MonoBehaviour {
public AudioClip[] audioClip;
void OnTriggerEnter(Collider other)
{
if (other.transform.tag == "Coin")
{
ScoreTextScript.coinAmount += 1;
PlaySound(0);
Destroy(other.gameObject);
}
}
void PlaySound(int clip)
{
audio.clip = audioClip[clip];
audio.Play();
}
}
]
errors:
-
- Assets/PlayerCoinSFX.cs(20,9): error CS1061: Type `UnityEngine.Component' does not contain a definition for `clip' and no extension method `clip' of type `UnityEngine.Component' could be found. Are you missing an assembly reference?
-
- Assets/PlayerCoinSFX.cs(21,9): error CS1061: Type `UnityEngine.Component' does not contain a definition for `Play' and no extension method `Play' of type `UnityEngine.Component' could be found. Are you missing an assembly reference?