-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathObjectsInRange.cs
More file actions
32 lines (27 loc) · 806 Bytes
/
ObjectsInRange.cs
File metadata and controls
32 lines (27 loc) · 806 Bytes
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
30
31
32
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ObjectsInRange : MonoBehaviour
{
[Header("Settings")]
[SerializeField] private Collider[] _GameObjectsInRange = new Collider[0];
[SerializeField] private LayerMask _Layer;
[SerializeField] private float _Range = 5;
void Start()
{
CheckObjectsInRange();
}
void Update()
{
//CheckObjectsInRange();
}
public void CheckObjectsInRange()
{
_GameObjectsInRange = Physics.OverlapSphere(transform.position, _Range, _Layer);
Debug.Log("Objects in range: " + _GameObjectsInRange.Length.ToString());
for (int i = 0; i < _GameObjectsInRange.Length; i++)
{
Debug.Log(_GameObjectsInRange[i].name);
}
}
}