How to enable a panel after collision
I want to show a panel when my character bumps to an object. My object's tag is 'apple', and my panel's tag is 'apel'. However, when the character is bumbing to the object the panel won't show. void OnTriggerEnter(Collider col) { if (col.tag == "apple") { Destroy(col.gameObject); GameObject[] gameObjectArray = GameObject.FindGameObjectsWithTag("apel"); foreach(GameObject go in gameObjectArray) { go.SetActive(true); } } }
Answer by diadhees · Aug 27, 2017 at 05:52 PM
I found the solution already. So, instead of using tag on the panel, I called the panel using 'public GameObject apel' and drag the panel to this field on Inspector tab of the character, under my script. Here is my code :
using UnityEngine; public class respwan : MonoBehaviour { public GameObject apel; public void OnTriggerEnter(Collider col) { if (col.tag == "apple") { Destroy(col.gameObject); apel.SetActive(true); } }}