I have a 2D asteroid game which spawn moving asteroids (spawn box) from left , right, above and below my main camera view. My original asteroids (objects) where place far away from my main camera and my spawn boxes so it wouldn’t come in at i time i didn’t give it. I made a boundary box around my main camera and my spawn box so it can destroy any asteroids (objects) that goes beyond that point. but it didn’t work. My problem is how can i make a boundary box using a box collider that destroy any objects that goes beyond it. WITHOUT destroying my original asteroids (objects). Here’s my boundary script :
using UnityEngine;
using System.Collections;
public class DestroyByBoundary : MonoBehaviour
{
void OnTriggerExit(Collider other)
{
Destroy(other.gameObject);
}
}