unity 动画正播放倒播(animation)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class door : MonoBehaviour
{
// private Transform door_transform;
public GameObject AnimationObj;
private Animation animation_A;
// Start is called before the first frame update
void Start()
{
animation_A = gameObject.GetComponent<Animation>();
}
void OnTriggerEnter(Collider coll)
{
if (coll.gameObject.name == "Student")
{
//AnimationObj.GetComponent<Animation>()["OpenDoorAni"].time = AnimationObj.GetComponent<Animation>()["OpenDoorAni"].clip.length;
//AnimationObj.GetComponent<Animation>()["OpenDoorAni"].speed = 1.0f;
//AnimationObj.GetComponent<Animation>().CrossFade("OpenDoorAni");
animation_A.Play("OpenDoorAni");
}
}
void OnTriggerExit(Collider coll)
{
// animation01["OpenDoorAni"].time = animation01["OpenDoorAni"].clip.length;
if (coll.gameObject.name == "Student")
{
AnimationObj.GetComponent<Animation>()["OpenDoorAni"].time = AnimationObj.GetComponent<Animation>()["OpenDoorAni"].clip.length;
AnimationObj.GetComponent<Animation>()["OpenDoorAni"].speed = -1.0f;
AnimationObj.GetComponent<Animation>().CrossFade("OpenDoorAni");
}
}
}
更多推荐
所有评论(0)