Debug.log not working when entering trigger zone.
Hello peoples! I have been having this problem with my development for a while, and didn't consider asking the Unity community about it. So, here is my problem. I have made an object (spikes) that is, at the moment, has a Debug.log function on it. I fixed the box collider to where it should kill the player on collision. I test it, and nothing pops up in the console. Here are the places in the scripts where it has the debug.log.
Script 1:
using UnityEngine;
using System.Collections;
public class LevelManager : MonoBehaviour {
public GameObject currentCheckpoint;
private PlayerMovement player;
// Use this for initialization
void Start () {
player = FindObjectOfType<PlayerMovement> ();
}
// Update is called once per frame
void Update () {
}
public void RespawnPlayer() {
Debug.Log ("Player Respawn");
}
}
Script 2:
using UnityEngine;
using System.Collections;
public class KillPlayer : MonoBehaviour {
public LevelManager levelManager;
// Use this for initialization
void Start () {
levelManager = FindObjectOfType<LevelManager>();
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter2D(Collider2D other)
{
if(other.name == "Player")
{
levelManager.RespawnPlayer();
}
}
}
If anybody could help me, that would be really appreciated. Thank you.
Does your Player object and Spike object have collider on them? Are those colliders set as 'Is Trigger = true'?
$$anonymous$$y player has a Circle Collider 2D, and my spikes have a Box Collider 2D. Only the spikes have Is Trigger = true.
Does your Player object have the "Player" tag? Has at least one of these objects have a rigidbody2D attached?
$$anonymous$$y player has the "Player" tag, and has a Rigidbody2D on it.
Hmm... Can you post a screenshot of the current settings of your rigidbody2D. have you checked the collision layers to make sure they accept collisions?
Answer by hexagonius · Jan 03, 2016 at 10:57 PM
you're comparing the name. Is it's name Player also? Put the debug first in OnTriggerEnter2D to see if THAT even works
Thank you! That fixed it! I guess I thought it was going to do the debug by tag. A rookie mistake. :)
don't really understand what you mean by that, but as long as it works now :)
I renamed my player to "Player". I originally named my player "Player (prototype)"
Your answer
Follow this Question
Related Questions
Stop moving Ball after respawn for seconds c# 0 Answers
Debug.Log Only Printing With Variable (Not string) 0 Answers
C# Respawn and Score Problem 1 Answer
How do i put "Wasted!" after respawn? 0 Answers