浏览代码

Merge pull request #1343 from Unity-Technologies/release-v0.6-tennis-fix

Fix for the tennis Agent. Works with prefab now
/develop-generalizationTraining-TrainerController
GitHub 6 年前
当前提交
c5905885
共有 1 个文件被更改,包括 17 次插入3 次删除
  1. 20
      UnitySDK/Assets/ML-Agents/Examples/Tennis/Scripts/TennisAgent.cs

20
UnitySDK/Assets/ML-Agents/Examples/Tennis/Scripts/TennisAgent.cs


public GameObject ball;
public bool invertX;
public int score;
public GameObject scoreText;
public GameObject opponent;
private Text textComponent;
private Rigidbody agentRb;

// Looks for the scoreboard based on the name of the gameObjects.
// Do not modify the names of the Score GameObjects
private const string CanvasName = "Canvas";
private const string ScoreBoardAName = "ScoreA";
private const string ScoreBoardBName = "ScoreB";
textComponent = scoreText.GetComponent<Text>();
var canvas = GameObject.Find(CanvasName);
GameObject scoreBoard;
if (invertX)
{
scoreBoard = canvas.transform.Find(ScoreBoardBName).gameObject;
}
else
{
scoreBoard = canvas.transform.Find(ScoreBoardAName).gameObject;
}
textComponent = scoreBoard.GetComponent<Text>();
}
public override void CollectObservations()

正在加载...
取消
保存