Displaying "Game over" when a collision occurs
Hi, I am creating a game where the player tries to avoid 6 objects. I want to display "Game Over" when the player collides with the pickup object. My script is below and I can not figure out why "Game Over" is not displaying. In my player object I have a Circle collider 2d (Is trigger not checked). Also in my Pickup object I have a circle collider (Is trigger not checked). Please help if you can
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class over : MonoBehaviour
{
public Text overText;
void Start()
{
overText.text = "";
}
void OnCollisionEnter(Collision col)
{
if (col.gameObject.name == "Pickup")
{
overText.text = "Game Over";
}
}
}
,
Comment