23 lines
622 B
C#
23 lines
622 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
public class BeamCollider : MonoBehaviour
|
|
{
|
|
public Laser thisLaser;
|
|
|
|
private void OnTriggerEnter2D(Collider2D other)
|
|
{
|
|
if (!other.CompareTag(thisLaser.thisPlayer.tag) && other.TryGetComponent(out Entity isEntity))
|
|
{
|
|
thisLaser.enemyList.Add(isEntity);
|
|
}
|
|
}
|
|
|
|
private void OnTriggerExit2D(Collider2D other)
|
|
{
|
|
if (!other.CompareTag(thisLaser.thisPlayer.tag) && other.TryGetComponent(out Entity isEntity) && thisLaser.enemyList.Contains(isEntity))
|
|
{
|
|
thisLaser.enemyList.Remove(isEntity);
|
|
}
|
|
}
|
|
}
|