Files
PrinceOfGlory/Assets/Scripts/Scene_04/ColliderPlay.cs
kridoo 4b527795f7 1
2025-09-30 17:21:50 +08:00

49 lines
1.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ColliderPlay : MonoBehaviour
{
public bool isRepeat = true;
bool isCanPlay = true;
AudioSource source;
public Animator animator;
//public Animator animator2;
// 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)
{
if(animator != null)
{
source.Play();
animator.Play("zr_2_shiyi");
}
else
{
source.Play();
if (!isRepeat)
{
isCanPlay = false;
}
}
}
}
}
}