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.