level 2
紫水晶84
楼主
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Opendoor : MonoBehaviour
{
// Start is called before the first frame update
//public Animator animator;
public Animation animation;
public GameObject Canve;
//public Collider Solid;
void Start()
{
Canve.SetActive(false);
}
void OnTriggerEnter (Collider Solid)
{
Debug.Log("Enter");
//animator.StartPlayback();
Debug.Log("ing");
Canve.SetActive(true);
//if (Input.GetKeyDown(KeyCode.E))
//{
// Debug.Log(Input.GetKeyDown(KeyCode.E));
// animation.Play();
//}
}
void OnTriggerStay (Collider Solid)
{
//animator.StartPlayback();
Debug.Log("Stay");
if (Input.GetKeyDown(KeyCode.E))
{
Debug.Log(Input.GetKeyDown(KeyCode.E));
animation.Play();
}
}
void OnTriggerExit (Collider Solid)
{
Canve.SetActive(false);
Debug.Log("Exct");
}
//void OnCollisionEnter (Collision Solid) 试探究Collision Enter和Trigger Enter的区别
//{
// //animator.StartPlayback();
// Debug.Log("ing");
// animation.Play();
//}
}
2023年11月16日 09点11分
1
using System.Collections.Generic;
using UnityEngine;
public class Opendoor : MonoBehaviour
{
// Start is called before the first frame update
//public Animator animator;
public Animation animation;
public GameObject Canve;
//public Collider Solid;
void Start()
{
Canve.SetActive(false);
}
void OnTriggerEnter (Collider Solid)
{
Debug.Log("Enter");
//animator.StartPlayback();
Debug.Log("ing");
Canve.SetActive(true);
//if (Input.GetKeyDown(KeyCode.E))
//{
// Debug.Log(Input.GetKeyDown(KeyCode.E));
// animation.Play();
//}
}
void OnTriggerStay (Collider Solid)
{
//animator.StartPlayback();
Debug.Log("Stay");
if (Input.GetKeyDown(KeyCode.E))
{
Debug.Log(Input.GetKeyDown(KeyCode.E));
animation.Play();
}
}
void OnTriggerExit (Collider Solid)
{
Canve.SetActive(false);
Debug.Log("Exct");
}
//void OnCollisionEnter (Collision Solid) 试探究Collision Enter和Trigger Enter的区别
//{
// //animator.StartPlayback();
// Debug.Log("ing");
// animation.Play();
//}
}