working on multiplayer
This commit is contained in:
29
Runtime/Engine/Code/Simulation/Sensors/RaycastSensor.cs
Normal file
29
Runtime/Engine/Code/Simulation/Sensors/RaycastSensor.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace RebootKit.Engine.Services.Simulation.Sensors {
|
||||
public class RaycastSensor : ISensor {
|
||||
public LayerMask layerMask;
|
||||
public float maxDistance;
|
||||
public Ray ray;
|
||||
|
||||
public bool HasHit { get; private set; }
|
||||
public RaycastHit Hit { get; private set; }
|
||||
|
||||
public GameObject Sense() {
|
||||
HasHit = Physics.Raycast(ray, out RaycastHit hit, maxDistance, layerMask);
|
||||
|
||||
if (HasHit) {
|
||||
Hit = hit;
|
||||
return Hit.transform.gameObject;
|
||||
}
|
||||
|
||||
Hit = default;
|
||||
return null;
|
||||
}
|
||||
|
||||
public void Clear() {
|
||||
HasHit = false;
|
||||
Hit = default;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user