浏览代码

cleanup & put direction indicator in separate script

/docs-update
Hunter-Unity 5 年前
当前提交
8bcce546
共有 11 个文件被更改,包括 1105 次插入40 次删除
  1. 27
      Project/Assets/ML-Agents/Examples/Walker/Prefabs/DynamicPlatformWalker.prefab
  2. 27
      Project/Assets/ML-Agents/Examples/Walker/Prefabs/WalkerWithTargetPair.prefab
  3. 6
      Project/Assets/ML-Agents/Examples/Walker/Scenes/WalkerDynamic.unity
  4. 4
      Project/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgent.cs
  5. 2
      Project/ProjectSettings/TimeManager.asset
  6. 27
      Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/DirectionIndicator.cs
  7. 11
      Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/DirectionIndicator.cs.meta
  8. 1001
      Project/Assets/ML-Agents/Examples/Walker/TFModels/WalkerDynamic CloudLast.nn
  9. 11
      Project/Assets/ML-Agents/Examples/Walker/TFModels/WalkerDynamic CloudLast.nn.meta
  10. 26
      Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/TransformExtensions.cs
  11. 3
      Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/TransformExtensions.cs.meta

27
Project/Assets/ML-Agents/Examples/Walker/Prefabs/DynamicPlatformWalker.prefab


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &693499830
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 555702846}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1513f8a85fedd47efba089213b7c5bde, type: 3}
m_Name:
m_EditorClassIdentifier:
transformToFollow: {fileID: 6065910099080495282}
targetToLookAt: {fileID: 4714470935848893865}
heightOffset: 0
--- !u!1 &4711180330649187171
GameObject:
m_ObjectHideFlags: 0

type: 3}
m_PrefabInstance: {fileID: 6359877978260855390}
m_PrefabAsset: {fileID: 0}
--- !u!4 &6065910099080495282 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 895268871264836332, guid: 765582efd9dda46ed98564603316353f,
type: 3}
m_PrefabInstance: {fileID: 6359877978260855390}
m_PrefabAsset: {fileID: 0}
--- !u!1 &555702846 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 6359877977706987616, guid: 765582efd9dda46ed98564603316353f,
type: 3}
m_PrefabInstance: {fileID: 6359877978260855390}
m_PrefabAsset: {fileID: 0}

27
Project/Assets/ML-Agents/Examples/Walker/Prefabs/WalkerWithTargetPair.prefab


m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!114 &928625103
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8076557379269661508}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1513f8a85fedd47efba089213b7c5bde, type: 3}
m_Name:
m_EditorClassIdentifier:
transformToFollow: {fileID: 2610895078055938504}
targetToLookAt: {fileID: 4085853164035250}
heightOffset: 0
--- !u!1001 &2906899243981837092
PrefabInstance:
m_ObjectHideFlags: 0

type: 3}
m_PrefabInstance: {fileID: 2906899243981837092}
m_PrefabAsset: {fileID: 0}
--- !u!4 &2610895078055938504 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 895268871264836332, guid: 765582efd9dda46ed98564603316353f,
type: 3}
m_PrefabInstance: {fileID: 2906899243981837092}
m_PrefabAsset: {fileID: 0}
--- !u!1 &8076557379269661508 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 6359877977706987616, guid: 765582efd9dda46ed98564603316353f,
type: 3}
m_PrefabInstance: {fileID: 2906899243981837092}
m_PrefabAsset: {fileID: 0}

6
Project/Assets/ML-Agents/Examples/Walker/Scenes/WalkerDynamic.unity


propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6065910098925129095, guid: f51e8260728fd4c8fa87bcda9d0e2027,
type: 3}
propertyPath: m_Model
value:
objectReference: {fileID: 11400000, guid: c6e746bbf8df5420689695d426340a3c,
type: 3}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: f51e8260728fd4c8fa87bcda9d0e2027, type: 3}
--- !u!1001 &3766798870867890383

4
Project/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgent.cs


[Space(10)]
//This will be used as a stable observation platform for the ragdoll to use.
GameObject m_OrientationCube;
public Transform directionIndicator;
[Header("Target To Walk Towards")]
[Space(10)]

//UPDATE ORIENTATION CUBE POS & ROT
m_OrientationCube.transform.position = hips.position;
m_OrientationCube.transform.rotation = m_WalkDirLookRot;
directionIndicator.position = new Vector3(hips.position.x, directionIndicator.position.y, hips.position.z);
directionIndicator.rotation = m_WalkDirLookRot;
}
public int fuTimer = 0;

2
Project/ProjectSettings/TimeManager.asset


m_ObjectHideFlags: 0
Fixed Timestep: 0.02
Maximum Allowed Timestep: 0.33333334
m_TimeScale: 20
m_TimeScale: 1
Maximum Particle Timestep: 0.03

27
Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/DirectionIndicator.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Unity.MLAgentsExamples
{
public class DirectionIndicator : MonoBehaviour
{
public Transform transformToFollow; //ex: hips or body
public Transform targetToLookAt; //target in the scene the indicator will point to
public float heightOffset;
private Vector3 m_StartingPos;
void OnEnable()
{
m_StartingPos = transform.position;
}
void Update()
{
transform.position = new Vector3(transformToFollow.position.x, m_StartingPos.y + heightOffset, transformToFollow.position.z);
Vector3 m_WalkDir = targetToLookAt.position - transform.position;
m_WalkDir.y = 0; //flatten dir on the y
transform.rotation = Quaternion.LookRotation(m_WalkDir);
}
}
}

11
Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/DirectionIndicator.cs.meta


fileFormatVersion: 2
guid: 1513f8a85fedd47efba089213b7c5bde
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

1001
Project/Assets/ML-Agents/Examples/Walker/TFModels/WalkerDynamic CloudLast.nn
文件差异内容过多而无法显示
查看文件

11
Project/Assets/ML-Agents/Examples/Walker/TFModels/WalkerDynamic CloudLast.nn.meta


fileFormatVersion: 2
guid: 47226119b21ca4b1e865ff54f7922bc9
ScriptedImporter:
fileIDToRecycleName:
11400000: main obj
11400002: model data
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 19ed1486aa27d4903b34839f37b8f69f, type: 3}

26
Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/TransformExtensions.cs


using UnityEngine;
/// <summary>
/// A Transform Extension that ignores scale for TransformPoint operations.
/// </summary>
public static class TransformExtensions
{
/// <summary>
/// Transform position from world space to local space unscaled.
/// </summary>
public static Vector3 TransformPointUnscaled(this Transform transform, Vector3 position)
{
var localToWorldMatrix = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
return localToWorldMatrix.MultiplyPoint3x4(position);
}
/// <summary>
/// Transform position from local space to world space unscaled.
/// </summary>
public static Vector3 InverseTransformPointUnscaled(this Transform transform, Vector3 position)
{
var worldToLocalMatrix = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one).inverse;
return worldToLocalMatrix.MultiplyPoint3x4(position);
}
}

3
Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/TransformExtensions.cs.meta


fileFormatVersion: 2
guid: cda45d40e2b1444597790f6a956db9a3
timeCreated: 1588782389
正在加载...
取消
保存