Unity Game Over Screen Not appearing when player hits objects.
Hi.. I am new to Unity. I am currently making Google Dino Game in Unity. I have almost finished it but i got a problem. My Game Over Screen is not appearing when the dino hit the cactus.
This is my code:
using UnityEngine;
public class PlayerCollision : MonoBehaviour
{
public GameObject gameOverScreen;
public Rigidbody2D body;
void OnCollisionEnter2D(Collision2D collision)
{
if (collision.transform.tag == "Enemy")
{
gameOverScreen.SetActive(true);
body.velocity = Vector2.zero;
}
}
}
Do i need to write more code or something? Pls help me.
Thx in advance!
New contributor
anonymous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.