Collision Not regestering

Hey, I’ve been working on a parkour/platformer game and I want it so when you fall you will teleport to another scene that says you died and a try again button, but its not working , it’ll just make him fall here’s the code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class deathScript : MonoBehaviour
{
     void OnCollisionEnter2D(Collision2D other) {
         if (other.gameObject.tag == "DEATH")
         {
           SceneManager.LoadScene("Loose scene");
         } else if (other.gameObject.tag == "")
         {

         }
     }


    
}

And here’s the pictures of my config

  • Comparing tags directly is not ideal, try using

    other.gameObject.CompareTag(“DEATH”)
    instead.

  • Also, where is your script attached to? Did you actually attach it to the player? If you didn’t that will never work.

  • Next question: did you add the scenes you want to load to the build settings? If they’re not setup correctly Unitt won’t be able to find them when you request the load.


The issue could be pretty much anything, if you have errors in the console please share those as well.

@XAlwalidX
Death script is not on the player unless character controller calls it