-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayerShieldInSight.cs
More file actions
29 lines (27 loc) · 1.13 KB
/
PlayerShieldInSight.cs
File metadata and controls
29 lines (27 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerShieldInSight : MonoBehaviour
{
[SerializeField] BoxCollider2D boxcollider;
[SerializeField] float colliderDistance;
[SerializeField] float range;
[SerializeField] LayerMask enemylayer;
private meleeEnemy MeleeEnemy;
public bool EnemyINsight()
{
RaycastHit2D hit = Physics2D.BoxCast(boxcollider.bounds.center + transform.right * range * transform.localScale.x * colliderDistance, new Vector3(boxcollider.bounds.size.x * range,
boxcollider.bounds.size.y, boxcollider.bounds.size.z), 0, Vector2.left, 0, enemylayer);
if (hit.collider != null)
{
MeleeEnemy = hit.transform.GetComponent<meleeEnemy>();
}
return hit.collider != null;
}
private void OnDrawGizmos()
{
Gizmos.color = Color.blue;
Gizmos.DrawWireCube(boxcollider.bounds.center + transform.right * range * transform.localScale.x * colliderDistance,
new Vector3(boxcollider.bounds.size.x * range, boxcollider.bounds.size.y, boxcollider.bounds.size.z));
}
}