Hello, I am making game over menu. I have canvas and i put some text in it and when I play the canvas dissapear but when I hit collider nothing happens, I was trying to Debug text on collider but dosen’t work.
I am stuck.
Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class gameover : MonoBehaviour {
public Canvas cav;
public bool x;
public Collider coli;
private void Start()
{
cav = GetComponent<Canvas>();
x = false;
cav.gameObject.SetActive(false);
coli = GetComponent<Collider>();
}
void OnCollisionEnter(Collision coli)
{
if (coli.gameObject.tag == "toto")
{
Debug.Log("lolz");
x = true;
}
}
private void Update()
{
if (x == true)
{
cav.gameObject.SetActive(true);
}
if (x == false)
{
cav.gameObject.SetActive(false);
}
}
}