1 using System.Collections.Generic;
6 namespace droid.Runtime.Prototyping.Sensors.Rays {
7 [AddComponentMenu(SensorComponentMenuPath._ComponentMenuPath
9 + SensorComponentMenuPath._Postfix)]
12 [SerializeField] Vector3 _direction = Vector3.forward;
14 [SerializeField] RaycastHit _hit =
new RaycastHit();
17 Space1 _observation_space =
new Space1 {_Decimal_Granularity = 3, _Min_Value = 0, _Max_Value = 100.0f};
19 [Header(
"Observation", order = 103)]
21 float _observation_value = 0;
25 [SerializeField]
float _range = 100.0f;
27 public override string PrototypingTypeName {
28 get {
return "Raycast" + $
"{this._direction.x}{this._direction.y}{this._direction.z}"; }
31 public Space1 SingleSpace {
get {
return this._observation_value_space; } }
33 public float ObservationValue {
34 get {
return this._observation_value; }
44 public override IEnumerable<float> FloatEnumerable {
get {
return new[] {this.ObservationValue}; } }
47 if (Physics.Raycast(
this.transform.position,
this._direction, out
this._hit,
this._range)) {
48 this.ObservationValue = this._hit.distance;
50 this.ObservationValue = this._range;
55 [SerializeField] Color _color = Color.green;
57 void OnDrawGizmosSelected() {
59 var position = this.transform.position;
60 Debug.DrawLine(position, position - this._direction * this._range, this._color);
float ClipNormaliseRound(float v)
override void UpdateObservation()