(Unity)画面外に出た敵を破壊する。

(スクリプト)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemyMove : MonoBehaviour
{
    void Update()
    {
        transform.Translate(-Vector3.forward * Time.deltaTime);
    }

    // 画面外に出たら破壊する。
    private void OnBecameInvisible()
    {
        Destroy(gameObject);
    }
}

(実行結果)