1
votes

I'm a student and I'm doing a 2D platform game as a project but my programming skills are so bad(That's why I'm trying to do the code by myself) but I'm stuck on that and I don't really have an idea about whats going on. Let me explain.

I've got my Player GameObject with his script playerBehaviour actually working and a BoxCollider2D marked as a Trigger

This Player, also tagged as Player, it's inside a Trigger that belongs the the GameObject LiveZone, who has the DeathZone script below.

using UnityEngine; using System.Collections;

public class DeathZone : MonoBehaviour {

public PlayerBehaviour playerBehaviour;

void OnTriggerExit2D (Collider2D other) {
    if (other.tag == "Player") {
        playerBehaviour.respawn = true;
        Debug.Log ("Respawn");
    }
    Debug.Log ("Exit Collider");
}

}

I also tried to do it in a most common way, setting the limits of the "LiveZone" with some triggers to delimitate the area with "DeathZoneTriggers"(that's why the script was called DeathZone at first). But I had the same problem with the OnTriggerEnter2D ().

It looks like it doesn't want to detect my Player leaving or entering this area, as you can see I also called some Debugs, but are not working neither.

To organize information you may also need(or not): 2 GameObjects with Triggers "Player", who has to exit the zone and "AliveZone", who should detect who's leaving. Player is tagged as "Player", AliveZone has no tag(don't know if that would mean something)

Any idea?

1

1 Answers

1
votes

God I found what was wrong, I set a layer that was ignoring the deafault ones, so it wasn't interacting with that deathzone collider ._.

At least I finally found what was wrong with it, thx anyways for those who read it up and tried to think about a solution! :)