触碰检测
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ShuiHuScripts : MonoBehaviour {
public ModelXianShi xianShi;
public GameObject shuihuTS;
void OnTriggerEnter(Collider other)
{
if (other.tag == "MuZhuangtag") //如果水壶碰到木桩
{
//Destroy(other.gameObject); //销毁木桩
if (xianShi != null)
{
if (xianShi.Modle01[3] != null)
{
xianShi.Modle01[3].SetActive(true); //让挖掘机出现
}
if (xianShi.Modle01[2] != null)
{
//销毁木桩
xianShi.Modle01[2].SetActive(false); //木桩细线消失
}
if (xianShi.Modle01[4] != null)
{
xianShi.Modle01[4].SetActive(true); //放样线出现
}
if (xianShi.Modle01[3] != null)
{
xianShi.Modle01[3].SetActive(true); //挖掘机出现
}
}
//判断水壶提示图片是否隐藏
if (shuihuTS != null)
{
shuihuTS.SetActive(false);
}
//这个必须写在最后,这个销毁了,其他在这个脚本中的东西就不在执行了
Destroy(this.gameObject); //销毁水壶
}
}
}