Class GridSensorComponent
A SensorComponent that creates a GridSensorBase.
Namespace: Unity.MLAgents.Sensors
Syntax
public class GridSensorComponent : SensorComponent
Fields
m_SensorName
Declaration
protected string m_SensorName
Field Value
Type | Description |
---|---|
String |
Properties
AgentGameObject
The reference of the root of the agent. This is used to disambiguate objects with the same tag as the agent. Defaults to current GameObject.
Declaration
public GameObject AgentGameObject { get; set; }
Property Value
Type | Description |
---|---|
GameObject |
CellScale
The scale of each grid cell. Note that changing this after the sensor is created has no effect.
Declaration
public Vector3 CellScale { get; set; }
Property Value
Type | Description |
---|---|
Vector3 |
ColliderMask
The layer mask.
Declaration
public LayerMask ColliderMask { get; set; }
Property Value
Type | Description |
---|---|
LayerMask |
CompressionType
The compression type to use for the sensor.
Declaration
public SensorCompressionType CompressionType { get; set; }
Property Value
Type | Description |
---|---|
SensorCompressionType |
DebugColors
Array of Colors used for the grid gizmos.
Declaration
public Color[] DebugColors { get; set; }
Property Value
Type | Description |
---|---|
Color[] |
DetectableTags
List of tags that are detected. Note that changing this after the sensor is created has no effect.
Declaration
public string[] DetectableTags { get; set; }
Property Value
Type | Description |
---|---|
String[] |
GizmoYOffset
The height of the gizmos grid.
Declaration
public float GizmoYOffset { get; set; }
Property Value
Type | Description |
---|---|
Single |
GridSize
The number of grid on each side. Note that changing this after the sensor is created has no effect.
Declaration
public Vector3Int GridSize { get; set; }
Property Value
Type | Description |
---|---|
Vector3Int |
InitialColliderBufferSize
The Estimated Max Number of Colliders to expect per cell. This number is used to pre-allocate an array of Colliders in order to take advantage of the OverlapBoxNonAlloc Physics API. If the number of colliders found is >= InitialColliderBufferSize the array will be resized to double its current size. The hard coded absolute size is 500. Note that changing this after the sensor is created has no effect.
Declaration
public int InitialColliderBufferSize { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
MaxColliderBufferSize
The absolute max size of the Collider buffer used in the non-allocating Physics calls. In other words the Collider buffer will never grow beyond this number even if there are more Colliders in the Grid Cell. Note that changing this after the sensor is created has no effect.
Declaration
public int MaxColliderBufferSize { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
ObservationStacks
Whether to stack previous observations. Using 1 means no previous observations. Note that changing this after the sensor is created has no effect.
Declaration
public int ObservationStacks { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
RotateWithAgent
Rotate the grid based on the direction the agent is facing.
Declaration
public bool RotateWithAgent { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
SensorName
Name of the generated GridSensorBase object. Note that changing this at runtime does not affect how the Agent sorts the sensors.
Declaration
public string SensorName { get; set; }
Property Value
Type | Description |
---|---|
String |
ShowGizmos
Whether to show gizmos or not.
Declaration
public bool ShowGizmos { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
CreateSensors()
Create the ISensors. This is called by the Agent when it is initialized.
Declaration
public override ISensor[] CreateSensors()
Returns
Type | Description |
---|---|
ISensor[] | Created ISensor objects. |
Overrides
GetGridSensors()
Get an array of GridSensors to be added in this component. Override this method and return custom GridSensor implementations.
Declaration
protected virtual GridSensorBase[] GetGridSensors()
Returns
Type | Description |
---|---|
GridSensorBase[] | Array of grid sensors to be added to the component. |