I have object spawning at random locations that fall down, all of them have rigidbodies attached. I’ve created a zone where I want anything entering it be destroyed in order to clean all the leftover clones that bypass the player. Here’s my code.
enter code hereusing UnityEngine;
using System.Collections;
public class Cleaner : MonoBehaviour
{
void OnTriggerEnter2D (Collider2D other)
{
Destroy(other.gameObject);
Debug.Log ("Cought");
}
}
I’ve tried having both the zone and the objects set as triggers, tried both collision and trigger enter functions, tried both having rigidbodies…but to no avail. I just want the trigger zone to destroy anything that goes through it.
I’ve added a Debug.Log and it looks like this code doesn’t even register that something is passing through it.