This my first time making a game and I can’t get this to work.
I’ve spend at least 3 hours troubleshooting but I just don’t get it to work.
this is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class restart : MonoBehaviour
{
public GameObject gameOverText, RestartButton;
// Start is called before the first frame update
void Start()
{
gameOverText.SetActive(false);
RestartButton.SetActive(false);
}
void onCollisionEnter2D(Collision2D col)
{
if (col.gameObject.tag.Equals("Enemy"))
{
Debug.Log("It does work!");
gameOverText.SetActive(true);
RestartButton.SetActive(true);
gameObject.SetActive(false);
}
}
}
I even tried to make a really simple script to see if that would work but it sadly doesn’t.
This is the code I used for it:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class testcollision : MonoBehaviour
{
void onCollisionEnter2D(Collision2D coll)
{
Debug.Log("It works!");
}
}
I’ve probally been making a silly little mistake the whole time but I can’t seem to find it.
Someone please help