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"); ? ? ? ? } ? ? } }
|