Hey so im trying to play a sound effect when my ball in the game hits something, but I cant figure out…
Audio.Play() doesnt work, so I went to unity 2018.2 Documentation but it also says GetComponent was removed in 2018.2.
Heres my code, it compiles fine but then nothing happens:
public class Ball : MonoBehaviour {
AudioSource boing;
private void OnCollisionEnter2D(Collision2D collision)
{
if(tag == ("Breakable")
{
boing = GetComponent<AudioSource>();
boing.Play();
}
}
}
So, what should I do ?