LieutenantChampignon/Projet Unity/Lieutenant Champignon/Assets/Scripts/Collectable.cs

26 lines
551 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Collectable : MonoBehaviour
{
private bool playsound;
[SerializeField]
private AudioClip cliptoplay;
void Start(){
AudioSource audioplayer = GetComponent<AudioSource>();
playsound = audioplayer != null;
}
private void OnTriggerEnter(Collider other){
if (other.tag == "Player"){
if (playsound){
AudioSource.PlayClipAtPoint(cliptoplay, transform.position);
}
this.gameObject.SetActive(false);
}
}
}