You can use this code in the objects update method:
public class DestroyPlayAudio : MonoBehaviour
{
public AudioSource audioSource;
public AudioClip clip;
public float volume=0.5f;
void Update()
{
if (Input.GetButtonDown ("0"))
{
Raycast ray=Camera.main.ScreenPointToRay(Input.mousePosition);
Raycasthit hit;
if (Physics.Raycast(ray, out hit))
{
Destroy(hit.collider.gameObject);
audioSource.PlayOneShot(clip, volume);
}
}
}
}
Insert your audiofile in the variable slot in the Monobehaviour.
If you want to create games fast without coding learn and use Playmaker or Game Creator.
Thank you very much!!. You have helped me a lot!!
– jorgonExactly what i wanted.. cant we also tell.. if( Input.GetKey( "Fire1" ) ) { Destroy(gameObject); } ? cause the OnMouseDown i dont know what it means:P
– NewDeveloper_1