using System.Collections; using System.Collections.Generic; using UnityEngine; public class PinTrigger : MonoBehaviour { public GameObject part; public GameObject flag; public GameObject stand; public string triggerTag; private bool isTrigger = false; void OnTriggerEnter(Collider other) { if (other.tag == triggerTag) { //part.SetActive(false); flag.SetActive(true); isTrigger = true; } } void OnTriggerExit(Collider other) { if (other.tag == triggerTag) { part.SetActive(true); flag.SetActive(false); isTrigger = false; } } private void Update() { if (Input.GetMouseButtonUp(0)) { if (isTrigger) { part.SetActive(false); flag.SetActive(false); stand.SetActive(true); gameObject.SetActive(false); PinGM.target++; } } } }