41 lines
779 B
C#
41 lines
779 B
C#
using UnityEngine;
|
|
using UnityEngine.VFX;
|
|
|
|
public class ZepettoTrigger : MonoBehaviour
|
|
{
|
|
public VisualEffect vfx;
|
|
public Animator zepettoAnimator;
|
|
|
|
// Trigger À̸§ (Walk, Wave, Hug)
|
|
public string triggerName;
|
|
|
|
public float delayBeforeVFX;
|
|
|
|
private bool hasPlayed = false;
|
|
|
|
private void Start()
|
|
{
|
|
vfx.Stop();
|
|
}
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
if (hasPlayed) return;
|
|
if (!other.CompareTag("Player")) return;
|
|
|
|
hasPlayed = true;
|
|
|
|
Debug.Log("Player Triggered!");
|
|
|
|
// Animator Trigger ½ÇÇà
|
|
zepettoAnimator.SetTrigger(triggerName);
|
|
|
|
Invoke(nameof(PlayVFX), delayBeforeVFX);
|
|
}
|
|
|
|
private void PlayVFX()
|
|
{
|
|
vfx.Reinit();
|
|
vfx.Play();
|
|
}
|
|
} |