Commit 45f14ace authored by Cody A Burchett's avatar Cody A Burchett

toggle

parent ad28d51f
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ToggleEnemy : MonoBehaviour {
Camera cam;
public List<Collider2D> enemies;
List<BaseEnemy> disabledEnemies;
// Use this for initialization
void Start () {
cam = Camera.main;
}
// Update is called once per frame
void Update () {
//get frustum of camera
Plane[] camPlanes = GeometryUtility.CalculateFrustumPlanes(cam);
for (int i = 0; i < enemies.Count; i++)
{
//check if enemy is in view of camera and disable if not
if (!GeometryUtility.TestPlanesAABB(camPlanes, enemies[i].bounds))
{
enemies[i].gameObject.GetComponent<BaseEnemy>().enabled = false;
enemies.Remove(enemies[i]);
}
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment