HeavenStudio/Assets/Scripts/Sound.cs
2021-12-18 23:10:43 -05:00

25 lines
500 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Sound : MonoBehaviour
{
public AudioClip clip;
public float pitch;
private AudioSource audioSource;
private void Start()
{
audioSource = GetComponent<AudioSource>();
audioSource.PlayOneShot(clip);
StartCoroutine(play());
}
private IEnumerator play()
{
yield return new WaitForSeconds(clip.length);
Destroy(this.gameObject);
}
}