Method GetObjectData
GetObjectData(GameObject, int, float[])
Get the observation values of the detected game object. Default is to record the detected tag index.
This method can be overridden to encode the observation differently or get custom data from the object. When overriding this method, GetCellObservationSize() and IsDataNormalized() might also need to change accordingly.
Declaration
protected virtual void GetObjectData(GameObject detectedObject, int tagIndex, float[] dataBuffer)
Parameters
| Type | Name | Description |
|---|---|---|
| GameObject | detectedObject | The game object that was detected within a certain cell |
| int | tagIndex | The index of the detectedObject's tag in the DetectableObjects list |
| float[] | dataBuffer | The buffer to write the observation values. The buffer size is configured by GetCellObservationSize(). |
Examples
Here is an example of overriding GetObjectData to get the velocity of a potential Rigidbody:
protected override void GetObjectData(GameObject detectedObject, int tagIndex, float[] dataBuffer)
{
if (tagIndex == Array.IndexOf(DetectableTags, "RigidBodyObject"))
{
Rigidbody rigidbody = detectedObject.GetComponent<Rigidbody>();
dataBuffer[0] = rigidbody.velocity.x;
dataBuffer[1] = rigidbody.velocity.y;
dataBuffer[2] = rigidbody.velocity.z;
}
}