Struct RayPerceptionOutput.RayOutput
Contains the data generated from a single ray of a ray perception sensor.
Inherited Members
Namespace: Unity.MLAgents.Sensors
Assembly: Unity.ML-Agents.dll
Syntax
public struct RayPerceptionOutput.RayOutput
Fields
EndPositionWorld
End position of the ray in world space.
Declaration
public Vector3 EndPositionWorld
Field Value
Type | Description |
---|---|
Vector3 |
HasHit
Whether or not the ray hit anything.
Declaration
public bool HasHit
Field Value
Type | Description |
---|---|
bool |
HitFraction
Normalized distance to the hit object.
Declaration
public float HitFraction
Field Value
Type | Description |
---|---|
float |
HitGameObject
The hit GameObject (or null if there was no hit).
Declaration
public GameObject HitGameObject
Field Value
Type | Description |
---|---|
Game |
HitTagIndex
The index of the hit object's tag in the DetectableTags list, or -1 if there was no hit, or the hit object has a different tag.
Declaration
public int HitTagIndex
Field Value
Type | Description |
---|---|
int |
HitTaggedObject
Whether or not the ray hit an object whose tag is in the input's DetectableTags list.
Declaration
public bool HitTaggedObject
Field Value
Type | Description |
---|---|
bool |
ScaledCastRadius
The scaled size of the cast.
Declaration
public float ScaledCastRadius
Field Value
Type | Description |
---|---|
float |
Remarks
If there is non-(1,1,1) scale, the cast radius will be also be scaled.
StartPositionWorld
Start position of the ray in world space.
Declaration
public Vector3 StartPositionWorld
Field Value
Type | Description |
---|---|
Vector3 |
Properties
ScaledRayLength
The scaled length of the ray.
Declaration
public float ScaledRayLength { get; }
Property Value
Type | Description |
---|---|
float |
Remarks
If there is non-(1,1,1) scale, |EndPositionWorld - StartPositionWorld| will be different from the input rayLength.
Methods
ToFloatArray(int, int, float[])
Writes the ray output information to a subset of the float array. Each element in the rayAngles array determines a sublist of data to the observation. The sublist contains the observation data for a single cast. The list is composed of the following:
- A one-hot encoding for detectable tags. For example, if DetectableTags.Length = n, the first n elements of the sublist will be a one-hot encoding of the detectableTag that was hit, or all zeroes otherwise.
- The 'numDetectableTags' element of the sublist will be 1 if the ray missed everything, or 0 if it hit something (detectable or not).
- The 'numDetectableTags+1' element of the sublist will contain the normalized distance to the object hit, or 1.0 if nothing was hit.
Declaration
public void ToFloatArray(int numDetectableTags, int rayIndex, float[] buffer)