Download Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/CameraFollow.cs from ashish2244/ppo-SnowballTarget: direct link, hf CLI and curl.
- Browser
- Download file 1 kB
-
https://huggingface.co/ashish2244/ppo-SnowballTarget/resolve/main/Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/CameraFollow.cs
- Command line
-
hf download hf://ashish2244/ppo-SnowballTarget/Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/CameraFollow.cs
-
curl -L -o CameraFollow.cs https://huggingface.co/ashish2244/ppo-SnowballTarget/resolve/main/Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/CameraFollow.cs
1 kB
| using UnityEngine; | |
| namespace Unity.MLAgentsExamples | |
| { | |
| public class CameraFollow : MonoBehaviour | |
| { | |
| [] public Transform target; | |
| [] | |
| 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); | |
| } | |
| } | |
| } | |