浏览代码

faster x axis/less rotation

/asymm-envs
Andrew Cohen 5 年前
当前提交
765dfb4d
共有 2 个文件被更改,包括 3 次插入3 次删除
  1. 4
      Project/Assets/ML-Agents/Examples/Tennis/Scripts/TennisAgent.cs
  2. 2
      Project/Assets/ML-Agents/Examples/Tennis/Scripts/TennisArea.cs

4
Project/Assets/ML-Agents/Examples/Tennis/Scripts/TennisAgent.cs


m_AgentRb.AddForce(new Vector3(moveX * 5f, upward * 10f, 0f), ForceMode.VelocityChange);
// calculate angle between m_InvertMult * 35 and m_InvertMult * 145
var angle = 55f * rotate + m_InvertMult * k_Angle;
// calculate angle between m_InvertMult * 55 and m_InvertMult * 125
var angle = 35f * rotate + m_InvertMult * k_Angle;
// maps inverse agents rotation into -35 to -145
var rotateZ = angle - (gameObject.transform.rotation.eulerAngles.z - (1f - m_InvertMult) * 180f);
Quaternion deltaRotation = Quaternion.Euler(zAxis * rotateZ);

2
Project/Assets/ML-Agents/Examples/Tennis/Scripts/TennisArea.cs


{
m_BallRb.AddForce(down);
var rgV = m_BallRb.velocity;
m_BallRb.velocity = new Vector3(Mathf.Clamp(rgV.x, -30f, 30f), Mathf.Min(rgV.y, 35f), rgV.z);
m_BallRb.velocity = new Vector3(Mathf.Clamp(rgV.x, -40f, 40f), Mathf.Min(rgV.y, 35f), rgV.z);
}
}
正在加载...
取消
保存