diff --git a/MAEasySimulator/Assets/SpyAgent.cs b/MAEasySimulator/Assets/SpyAgent.cs index 798b654..1855209 100644 --- a/MAEasySimulator/Assets/SpyAgent.cs +++ b/MAEasySimulator/Assets/SpyAgent.cs @@ -7,6 +7,11 @@ public class SpyAgent : Agent { + + [Header("Sensor Settings")] + public int SensorCount = 5; + public float SensorDistance = 10f; + private Transform Sensor; private float rayDistance = 40f; // レイキャストの距離 //TODO:以下複数の避難所を検出する場合の対応 @@ -22,6 +27,8 @@ public class SpyAgent : Agent { private OnFindShelter _onFindShelter; private string LogPrefix = "[Agent Spy]"; private Vector3 StartPosition; + + private Ray SpySensor; void Start() { _controller = GetComponent(); @@ -33,6 +40,7 @@ void Start() { _controller.onChargingBattery += OnChargingBattery; Sensor = transform.Find("Sensor"); StartPosition = transform.localPosition; + SpySensor = new Ray(Sensor.position, Sensor.forward); } public override void OnEpisodeBegin() { @@ -58,6 +66,7 @@ public override void CollectObservations(VectorSensor sensor) { } sensor.AddObservation(targetPos); sensor.AddObservation(isFindTarget); + Debug.DrawRay(SpySensor.origin, SpySensor.direction * 10, Color.red, 5); } public override void OnActionReceived(ActionBuffers actions) { diff --git a/MAEasySimulator/Assets/SpyAgent.prefab b/MAEasySimulator/Assets/SpyAgent.prefab index 84d2c39..69b01ca 100644 --- a/MAEasySimulator/Assets/SpyAgent.prefab +++ b/MAEasySimulator/Assets/SpyAgent.prefab @@ -9,7 +9,6 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 4346805486820663787} - - component: {fileID: 782739389039547031} m_Layer: 0 m_Name: Sensor m_TagString: Untagged @@ -32,34 +31,6 @@ Transform: m_Father: {fileID: 5917736595786903999} m_RootOrder: -1 m_LocalEulerAnglesHint: {x: 44.045, y: 0, z: 0} ---- !u!114 &782739389039547031 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 6291193101612035988} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3} - m_Name: - m_EditorClassIdentifier: - m_SensorName: RayPerceptionSensor - m_DetectableTags: - - Shelter - m_RaysPerDirection: 3 - m_MaxRayDegrees: 70 - m_SphereCastRadius: 0.5 - m_RayLength: 40 - m_RayLayerMask: - serializedVersion: 2 - m_Bits: 4294967291 - m_ObservationStacks: 1 - m_AlternatingRayOrder: 1 - rayHitColor: {r: 1, g: 0, b: 0, a: 1} - rayMissColor: {r: 1, g: 1, b: 1, a: 1} - m_StartVerticalOffset: 0 - m_EndVerticalOffset: 0 --- !u!1 &6760585562241815342 GameObject: m_ObjectHideFlags: 0