浏览代码

cleanup from PR review

/active-variablespeed
HH 4 年前
当前提交
ab60431e
共有 7 个文件被更改,包括 15 次插入69 次删除
  1. 16
      Project/Assets/ML-Agents/Examples/SharedAssets/Prefabs/Targets/DynamicTarget.prefab
  2. 13
      Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/DirectionIndicator.cs
  3. 4
      Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/OrientationCubeController.cs
  4. 4
      Project/Assets/ML-Agents/Examples/Walker/Prefabs/Ragdoll/WalkerRagdollDySingleSpeedVariant.prefab
  5. 4
      Project/Assets/ML-Agents/Examples/Walker/Prefabs/Ragdoll/WalkerRagdollDyVariableSpeedVariant.prefab
  6. 32
      Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/RandomTorqueEveryXSec.cs
  7. 11
      Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/RandomTorqueEveryXSec.cs.meta

16
Project/Assets/ML-Agents/Examples/SharedAssets/Prefabs/Targets/DynamicTarget.prefab


- component: {fileID: 3826955612593018128}
- component: {fileID: 3858402326794362026}
- component: {fileID: 3631016866778687563}
- component: {fileID: 5100011760572799339}
m_Layer: 0
m_Name: DynamicTarget
m_TagString: target

onCollisionExitEvent:
m_PersistentCalls:
m_Calls: []
--- !u!114 &5100011760572799339
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3840539935788495952}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ab1096666cc514d9aac1e289b32ccfc5, type: 3}
m_Name:
m_EditorClassIdentifier:
maxTorque: {x: 100, y: 100, z: 100}
randomizeTorqueEveryXSec: 10
forceMode: 0

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


{
public class DirectionIndicator : MonoBehaviour
{
public bool updateViaScript;
public bool updatedByAgent; //should this be updated by the agent? If not, it will use local settings
public Transform transformToFollow; //ex: hips or body
public Transform targetToLookAt; //target in the scene the indicator will point to
public float heightOffset;

void Update()
{
if (updateViaScript) return;
if (updatedByAgent) return;
transform.position = new Vector3(transformToFollow.position.x, m_StartingYPos + heightOffset,
transformToFollow.position.z);
Vector3 walkDir = targetToLookAt.position - transform.position;

public void SetPosAndDir(Vector3 pos, Vector3 lookDir)
{
transform.position = new Vector3(pos.x, m_StartingYPos + heightOffset, pos.z);
lookDir.y = 0; //flatten dir on the y
transform.rotation = Quaternion.LookRotation(lookDir);
}
//Public method to allow an agent to directly update this component
public void MatchOrientation(Transform t)
{
transform.position = new Vector3(t.position.x, m_StartingYPos + heightOffset, t.position.z);

4
Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/OrientationCubeController.cs


/// </summary>
public class OrientationCubeController : MonoBehaviour
{
//Update position and Rotation
//Public method to allow Agent to set look rotation of this transform
//This method will be deprecated in future PR
public void UpdateOrientation(Transform rootBP, Transform target)
{
var dirVector = target.position - transform.position;

transform.SetPositionAndRotation(rootBP.position, lookRot);
}
//Public method to allow Agent to set look rotation of this transform
public void UpdateOrientation(Vector3 pos, Vector3 dirVector)
{
dirVector.y = 0; //flatten dir on the y. this will only work on level surfaces

4
Project/Assets/ML-Agents/Examples/Walker/Prefabs/Ragdoll/WalkerRagdollDySingleSpeedVariant.prefab


propertyPath: updateViaScript
value: 1
objectReference: {fileID: 0}
- target: {fileID: 693499830, guid: 765582efd9dda46ed98564603316353f, type: 3}
propertyPath: updatedByAgent
value: 1
objectReference: {fileID: 0}
- target: {fileID: 895268871377934275, guid: 765582efd9dda46ed98564603316353f,
type: 3}
propertyPath: m_Name

4
Project/Assets/ML-Agents/Examples/Walker/Prefabs/Ragdoll/WalkerRagdollDyVariableSpeedVariant.prefab


propertyPath: updateViaScript
value: 1
objectReference: {fileID: 0}
- target: {fileID: 693499830, guid: 765582efd9dda46ed98564603316353f, type: 3}
propertyPath: updatedByAgent
value: 1
objectReference: {fileID: 0}
- target: {fileID: 895268871377934275, guid: 765582efd9dda46ed98564603316353f,
type: 3}
propertyPath: m_Name

32
Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/RandomTorqueEveryXSec.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RandomTorqueEveryXSec : MonoBehaviour
{
public Vector3 maxTorque;
private Vector3 torqueToUse;
public float randomizeTorqueEveryXSec = 10;
public ForceMode forceMode;
private Rigidbody rb;
// Start is called before the first frame update
void OnEnable()
{
rb = GetComponent<Rigidbody>();
InvokeRepeating("SetRandomTorque", 0, randomizeTorqueEveryXSec);
}
void SetRandomTorque()
{
torqueToUse = new Vector3(Random.Range(-maxTorque.x, maxTorque.x), Random.Range(-maxTorque.y, maxTorque.y),
Random.Range(-maxTorque.z, maxTorque.z));
}
// Update is called once per frame
void FixedUpdate()
{
rb.AddRelativeTorque(torqueToUse, forceMode);
}
}

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


fileFormatVersion: 2
guid: ab1096666cc514d9aac1e289b32ccfc5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存