using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class OnOffLight2 : MonoBehaviour {
private Light m_light;
// Use this for initialization
void Start () {
m_light = GameObject.Find("Point light").GetComponent<Light>();
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter(Collider other) {
if (other.gameObject.name == "Player") {
m_light.enabled = true;
}
}
void OnTriggerExit(Collider other)
{
if (other.gameObject.name == "Player")
{
m_light.enabled = false;
}
}
}
Unity3D学习记录——触发器开关灯
最新推荐文章于 2024-08-21 02:53:04 发布