diff --git a/com.unity.ml-agents/Editor/VectorSensorComponentEditor.cs b/com.unity.ml-agents/Editor/VectorSensorComponentEditor.cs
index 883153aab1..aae6fd796f 100644
--- a/com.unity.ml-agents/Editor/VectorSensorComponentEditor.cs
+++ b/com.unity.ml-agents/Editor/VectorSensorComponentEditor.cs
@@ -21,6 +21,7 @@ public override void OnInspectorGUI()
EditorGUILayout.PropertyField(so.FindProperty("m_SensorName"), true);
EditorGUILayout.PropertyField(so.FindProperty("m_ObservationSize"), true);
EditorGUILayout.PropertyField(so.FindProperty("m_ObservationType"), true);
+ EditorGUILayout.PropertyField(so.FindProperty("m_ObservationStacks"), true);
}
EditorGUI.EndDisabledGroup();
diff --git a/com.unity.ml-agents/Runtime/Sensors/VectorSensorComponent.cs b/com.unity.ml-agents/Runtime/Sensors/VectorSensorComponent.cs
index 4dc61f05c3..26deb7434f 100644
--- a/com.unity.ml-agents/Runtime/Sensors/VectorSensorComponent.cs
+++ b/com.unity.ml-agents/Runtime/Sensors/VectorSensorComponent.cs
@@ -46,6 +46,21 @@ public ObservationType ObservationType
set { m_ObservationType = value; }
}
+ [HideInInspector, SerializeField]
+ [Range(1, 50)]
+ [Tooltip("Number of camera frames that will be stacked before being fed to the neural network.")]
+ int m_ObservationStacks = 1;
+
+ ///
+ /// Whether to stack previous observations. Using 1 means no previous observations.
+ /// Note that changing this after the sensor is created has no effect.
+ ///
+ public int ObservationStacks
+ {
+ get { return m_ObservationStacks; }
+ set { m_ObservationStacks = value; }
+ }
+
///
/// Creates a VectorSensor.
///
@@ -53,6 +68,10 @@ public ObservationType ObservationType
public override ISensor[] CreateSensors()
{
m_Sensor = new VectorSensor(m_ObservationSize, m_SensorName, m_ObservationType);
+ if (ObservationStacks != 1)
+ {
+ return new ISensor[] { new StackingSensor(m_Sensor, ObservationStacks) };
+ }
return new ISensor[] { m_Sensor };
}