Files
PrinceOfGlory/Assets/Scripts/Scene_05/SingleTouchPlayAnimator.cs
kridoo 5ba318796f 1
2025-11-14 19:34:36 +08:00

85 lines
2.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SingleTouchPlayAnimator : MonoBehaviour
{
//public GameObject animatorDaoJiu;
public GameObject animatorDaoJiuzhu;
Animator animator;
Animator animatorpig;
//计时相关
//bool isRun = false;
//float waitTime = 5f;
//float runTime = 0;
// Start is called before the first frame update
void Start()
{
animator = GetComponent<Animator>();
animatorpig= animatorDaoJiuzhu.GetComponent<Animator>();
//if (animatorDaoJiu != null)
//{
// animatorDaoJiu.SetActive(false);
//}
}
[Header("动画控制")]
[SerializeField] private Animator childAnimator; // 直接拖动绑定
[SerializeField] private Animator childAnimator2; // 直接拖动绑定
public void SetTriggerParameter(string parameterName)
{
if (childAnimator != null)
{
childAnimator.SetTrigger(parameterName);
}
if (childAnimator2 != null)
{
childAnimator2.SetTrigger(parameterName);
}
}
private void Update()
{
//if (isRun)
//{
// runTime += Time.deltaTime;
// if (runTime > waitTime)
// {
// isRun = false;
// runTime = 0;
//if (animatorDaoJiu != null)
//{
// animatorDaoJiu.SetActive(false);
//}
// }
//}
}
[SerializeField] private GameObject Vfx;
[SerializeField] private GameObject Vfx1;
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.name == "PalmBox_L" || other.gameObject.name == "PalmBox_R")
{
SetTriggerParameter("DisTrigger");
if (Vfx != null)
{
Destroy(Vfx);
Vfx = null;
}
if (Vfx1 != null)
{
Destroy(Vfx1);
Vfx1 = null;
}
animator.Play("Touch");
animatorpig.Play("Touch");
}
//if (animatorDaoJiu != null)
//{
// animatorDaoJiu.SetActive(true);
// animatorDaoJiu.GetComponent<Animator>().Play("Touch");
// isRun = true;
//}
}
}