Files
PrinceOfGlory/Assets/Scripts/Scene_04/ColliderPlay.cs
kridoo 6e91a0c7f0 111
2025-09-15 17:32:08 +08:00

33 lines
707 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ColliderPlay : MonoBehaviour
{
public bool isRepeat = true;
bool isCanPlay = true;
AudioSource source;
// Start is called before the first frame update
void Start()
{
source = GetComponent<AudioSource>();
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.name == "XROriginHands" || other.gameObject.name == "Main Camera")
{
if (!isCanPlay) return;
if (source != null)
source.Play();
if (!isRepeat)
{
isCanPlay = false;
}
}
}
}