浏览代码

center the sensor around game object not root

/develop/grid-rootref-debug
Ruo-Ping Dong 4 年前
当前提交
3af98268
共有 3 个文件被更改,包括 12 次插入4 次删除
  1. 11
      com.unity.ml-agents/Runtime/Sensors/BoxOverlapChecker.cs
  2. 1
      com.unity.ml-agents/Runtime/Sensors/GridSensorComponent.cs
  3. 4
      com.unity.ml-agents/Tests/Runtime/Sensor/BoxOverlapCheckerTests.cs

11
com.unity.ml-agents/Runtime/Sensors/BoxOverlapChecker.cs


Vector3Int m_GridSize;
bool m_RotateWithAgent;
LayerMask m_ColliderMask;
GameObject m_CenterObject;
GameObject m_RootReference;
string[] m_DetectableTags;
int m_InitialColliderBufferSize;

Vector3Int gridSize,
bool rotateWithAgent,
LayerMask colliderMask,
GameObject centerObject,
GameObject rootReference,
string[] detectableTags,
int initialColliderBufferSize,

m_GridSize = gridSize;
m_RotateWithAgent = rotateWithAgent;
m_ColliderMask = colliderMask;
m_CenterObject = centerObject;
m_RootReference = rootReference;
m_DetectableTags = detectableTags;
m_InitialColliderBufferSize = initialColliderBufferSize;

{
if (m_RotateWithAgent)
{
return m_RootReference.transform.TransformPoint(m_CellLocalPositions[cellIndex]);
return m_CenterObject.transform.TransformPoint(m_CellLocalPositions[cellIndex]);
return m_CellLocalPositions[cellIndex] + m_RootReference.transform.position;
return m_CellLocalPositions[cellIndex] + m_CenterObject.transform.position;
return m_RotateWithAgent ? m_RootReference.transform.rotation : Quaternion.identity;
return m_RotateWithAgent ? m_CenterObject.transform.rotation : Quaternion.identity;
}
/// <summary>

}
var closestColliderPoint = foundColliders[i].ClosestPointOnBounds(cellCenter);
var currentDistanceSquared = (closestColliderPoint - m_RootReference.transform.position).sqrMagnitude;
var currentDistanceSquared = (closestColliderPoint - m_CenterObject.transform.position).sqrMagnitude;
if (currentDistanceSquared >= minDistanceSquared)
{

1
com.unity.ml-agents/Runtime/Sensors/GridSensorComponent.cs


m_GridSize,
m_RotateWithAgent,
m_ColliderMask,
gameObject,
RootReference,
m_DetectableTags,
m_InitialColliderBufferSize,

4
com.unity.ml-agents/Tests/Runtime/Sensor/BoxOverlapCheckerTests.cs


Vector3Int gridSize,
bool rotateWithAgent,
LayerMask colliderMask,
GameObject centerObject,
GameObject rootReference,
string[] detectableTags,
int initialColliderBufferSize,

gridSize,
rotateWithAgent,
colliderMask,
centerObject,
rootReference,
detectableTags,
initialColliderBufferSize,

int gridSizeX = 10,
int gridSizeZ = 10,
bool rotateWithAgent = true,
GameObject centerObject = null,
GameObject rootReference = null,
string[] detectableTags = null,
int initialColliderBufferSize = 4,

new Vector3Int(gridSizeX, 1, gridSizeZ),
rotateWithAgent,
LayerMask.GetMask("Default"),
centerObject,
rootReference,
detectableTags,
initialColliderBufferSize,

正在加载...
取消
保存