Unity 机器学习代理工具包 (ML-Agents) 是一个开源项目,它使游戏和模拟能够作为训练智能代理的环境。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

31 行
1000 B

using UnityEngine;
namespace Unity.MLAgentsExamples
{
public class CameraFollow : MonoBehaviour
{
[Tooltip("The target to follow")] public Transform target;
[Tooltip("The time it takes to move to the new position")]
public float smoothingTime; //The time it takes to move to the new position
private Vector3 m_Offset;
private Vector3 m_CamVelocity; //Camera's velocity (used by SmoothDamp)
// Use this for initialization
void Start()
{
m_Offset = gameObject.transform.position - target.position;
}
void FixedUpdate()
{
var newPosition = new Vector3(target.position.x + m_Offset.x, transform.position.y,
target.position.z + m_Offset.z);
gameObject.transform.position =
Vector3.SmoothDamp(transform.position, newPosition, ref m_CamVelocity, smoothingTime, Mathf.Infinity,
Time.fixedDeltaTime);
}
}
}