fgm24/Assets/Scripts/Enemy/ShootingRange.cs

26 lines
545 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ShootingRange : MonoBehaviour
{
public float range = 5f;
public LayerMask playerLayer;
public bool inRange = false;
public GameObject target;
void Update()
{
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.CompareTag("Player"))
{
inRange = true;
target = collision.GetComponent<GameObject>();
}
else
inRange = false;
}
}