29 lines
883 B
C#
29 lines
883 B
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using Cysharp.Threading.Tasks;
|
||
|
using UnityEngine;
|
||
|
namespace BITKit.Sensors
|
||
|
{
|
||
|
public class RaySensor : Sensor
|
||
|
{
|
||
|
[Header(Constant.Header.Settings)]
|
||
|
public float distance;
|
||
|
public override IEnumerable<Transform> Get() => detecteds;
|
||
|
public override UniTask Excute()
|
||
|
{
|
||
|
if (Physics.Raycast(transform.position, transform.forward, out var rayhit, distance, detectLayer))
|
||
|
{
|
||
|
detecteds = new Transform[]{
|
||
|
rayhit.transform
|
||
|
};
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
detecteds = new Transform[0];
|
||
|
}
|
||
|
return UniTask.CompletedTask;
|
||
|
}
|
||
|
public override bool IsValid(Collider collider) => true;
|
||
|
public override float GetDistance() => distance;
|
||
|
}
|
||
|
}
|