diff --git a/com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensorComponentBase.cs b/com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensorComponentBase.cs index 7ae924e839..fa39c32ac7 100644 --- a/com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensorComponentBase.cs +++ b/com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensorComponentBase.cs @@ -209,15 +209,16 @@ public override ISensor[] CreateSensors() internal static float[] GetRayAngles(int raysPerDirection, float maxRayDegrees) { // Example: - // { 90, 90 - delta, 90 + delta, 90 - 2*delta, 90 + 2*delta } + // { 90 - 3*delta, 90 - 2*delta, ..., 90, 90 + delta, ..., 90 + 3*delta } var anglesOut = new float[2 * raysPerDirection + 1]; var delta = maxRayDegrees / raysPerDirection; - anglesOut[0] = 90f; - for (var i = 0; i < raysPerDirection; i++) + + for (var i = 0; i < 2 * raysPerDirection + 1; i++) { - anglesOut[2 * i + 1] = 90 - (i + 1) * delta; - anglesOut[2 * i + 2] = 90 + (i + 1) * delta; + // 90 - (num_rays) * delta + i * delta + anglesOut[i] = 90 - (raysPerDirection - i) * delta; } + return anglesOut; }