我是 c# 的菜鸟。当刚体进入设置为 Is Trigger 的盒对撞机时,我一直在尝试触发动画“命中”。我有动画剪辑,控制台显示我有“进入触发器”。一旦发生这种情况,我似乎无法播放我的动画剪辑。顺便说一下,这是关于 3D 模型的。任何人都可以帮忙吗?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class newAttack : MonoBehaviour {
public GameObject tiger;
public AnimationClip attack;
private Animation myAnimation;
/* IEnumerator Wait()
{
myAnimation = GetComponent<Animation>();
myAnimation.Play(attack.name);
yield return new WaitForSeconds(3);
}
*/
void OnTriggerEnter(Collider other)
{
Debug.Log("Entered Trigger");
myAnimation = GetComponent<Animation>();
myAnimation.Play(attack.name);
// StartCoroutine(Wait());
}
// Use this for initialization
// Update is called once per frame
void Update () {
}
}
相关分类