Hello everyone!
Okay so I have this small project working on, a 2D platformer, I’m still new to unity so this might be a little stupid… Anyways, my problem is that i’m tryiing to make a small code that respawns my player every time he collide with an object with deathObj tag I tried using OnTriggerEnter on another project before and it worked perfectly (3D game) but now it doesn’t seem to work at all. This is the code im using:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerDeath : MonoBehaviour {
void OnTriggerEnter2D(Collider2D deathObj)
{
if (deathObj.gameObject.CompareTag ("deathObj")) {
Debug.Log("You are dead!");
//for now im just trying to print this message in the console but nothing happens..
}
}
}
Also I’ve set up the tags on unity so that shouldn’t be the problem.
Thanks!