I’ve taken a little break from a project, but have recently updated to Unity 5.3.5 from 5.3.3 (Interestingly It had some kind of warning about updating - I can’t remember what it was specifically).
Onto the problem, I created an empty game object with a box collider2D and put a script on it to destroy game objects. This works beautifully on all colliders that have been in the project before the update, but when I create a new object with a box collider2D on it - it doesn’t collide at all! It doesn’t even recognize that it’s colliding. Yes I have checked the collision matrix as well, and it’s working as expected.
Here is the destroyer collider’s script (that destroys the out of bound objects):
using UnityEngine;
using UnityEngine.SceneManagement;
using System.Collections;
public class Destroyer : MonoBehaviour
{
int deathTime = 1;
void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.tag == "Player")
{
StartCoroutine(DeathAfterSec(deathTime));
}
Destroy(collision.gameObject);
if(collision.gameObject.tag == "Untagged")
{
Debug.Log("planksucks");
}
}
IEnumerator DeathAfterSec (int deathTime)
{
yield return new WaitForSeconds(deathTime);
SceneManager.LoadScene("Scene2");
}
}
Yes - I am trying to destroy the object named Plank ;p