oof ouch owie
This commit is contained in:
parent
e29208a2e5
commit
3364b5df68
5 changed files with 122 additions and 14 deletions
23
Assets/Scripts/BeamCollider.cs
Normal file
23
Assets/Scripts/BeamCollider.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue