- Home /
Play Sound on Destroy
So I have looked around the Internets and I haven't been able to find a decent explaination for my question. Basically I want a short clip to play after my character "picks up" a coin (more like destroys it). I've tried several times using different techniques so I just wanted to ask myself to see if anyone can tell me how to make this work. Here's the code, and if you need any clarification I'd be happy to help.
using UnityEngine;
using System.Collections;
public class PowerUpScript : MonoBehaviour {
HUDScript hud;
void OnTriggerEnter2D(Collider2D other)
{
if(other.tag == "Player")
{
hud = GameObject.Find ("Main Camera").GetComponent<HUDScript>();
hud.IncreaseScore(10);
Destroy (this.gameObject);
}
}
}
Comment
Best Answer
Answer by MakeCodeNow · Mar 11, 2014 at 10:28 PM
Easy. Just use AudioSource.PlayClipAtPoint()
Your answer
Follow this Question
Related Questions
Play Sound on Destroy 1 Answer
How to do 2d audio properly? 1 Answer
Attach audio source to different part of object 0 Answers
Make Sound Effects Not Audible Unless Near Them 2d? 1 Answer