所以我查了这个,但没有什么对我有用。我有一个动画,叫做“gemAnimation1”,我有一个盒子对撞机设置为触发。当它与播放器发生碰撞时,我希望它切换动画。这是我拼凑的代码,但它不起作用。动画“hasTouched”的触发器。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class gemCollider : MonoBehaviour {
private Animator animator;
void Start()
{
animator = GetComponent<Animator>();
}
void Update ()
{
}
void OnTriggerEnter (Collider other)
{
animator.SetTrigger("hasTouched");
}
}
编辑

