using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class OpenCloseDoor : MonoBehaviour {
private Transform m_transform;
// Use this for initialization
void Start () {
m_transform=GameObject.Find("DoorFather").GetComponent<Transform>();
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter(Collider other) {
if (other.gameObject.name == "Player") {
m_transform.Rotate(Vector3.up * 100);
}
}
void OnTriggerExit(Collider other) {
if (other.gameObject.name == "Player") {
m_transform.Rotate(Vector3.down * 100);
}
}
}
Unity3D学习记录——触发器开关门
最新推荐文章于 2024-06-17 09:00:00 发布