Hi! So I’ve got a gameObject that’s colliding with a box collider! When this happens there is a canvas that’s activating a text! Everything is okay till the moment when the two objects have to collide with each other… When the gameObject collide with the box collider the text I want to appear is doing it but only for a moment… Here is what I mean Gif > uEU_M5 is an Animated GIF Image on Make a GIF
and this is my code for the gameObject
public Text text;
public GameObject panel;
void Start()
{
text = GameObject.Find("sewingCanvas/GameObject/Panel/Text").GetComponent<Text>();
panel = GameObject.Find("sewingCanvas/GameObject/Panel");
panel.SetActive(false);
text.gameObject.SetActive(false);
}
void OnTriggerEnter(Collider co)
{
if (co.tag == "archieoPlaced")
{
panel.SetActive(true);
text.gameObject.SetActive(true);
text.text = "Правилно! ";
}
else if (co.tag == "shopPlaced" || co.tag == "schoolPlaced" || co.tag == "hospitalPlaced" || co.tag == "fitnessPlaced" || co.tag == "micPlaced" || co.tag == "shoesPlaced" || co.tag == "policePlaced" || co.tag == "firePlaced" || co.tag == "archPlaced" || co.tag == "programmerPlaced")
{
panel.SetActive(true);
text.gameObject.SetActive(true);
text.text = "Грешка! Опитайте с друг предмет ";
}
else
{
panel.SetActive(false);
text.gameObject.SetActive(false);
}
}
IEnumerator OnTriggerStay(Collider co)
{
yield return new WaitForSeconds(5);
if (co.tag == "schoolPlaced" || co.tag == "hospitalPlaced" || co.tag == "fitnessPlaced" || co.tag == "micPlaced" || co.tag == "shoesPlaced" || co.tag == "policePlaced" || co.tag == "firePlaced" || co.tag == "archPlaced" || co.tag == "archieoPlaced" || co.tag == "programmerPlaced")
{
panel.SetActive(false);
text.gameObject.SetActive(false);
gameObject.GetComponent<Pickupable>().enabled = false;
}
}
void OnTriggerExit(Collider co)
{
if (co.tag == "shopPlaced" || co.tag == "schoolPlaced" || co.tag == "hospitalPlaced" || co.tag == "fitnessPlaced" || co.tag == "micPlaced" || co.tag == "shoesPlaced" || co.tag == "policePlaced" || co.tag == "firePlaced" || co.tag == "archPlaced" || co.tag == "archieoPlaced" || co.tag == "programmerPlaced")
{
panel.SetActive(false);
text.gameObject.SetActive(false);
}
}