|
|
|
|
|
|
{ |
|
|
|
public class CameraFollow : MonoBehaviour |
|
|
|
{ |
|
|
|
public Transform target; |
|
|
|
Vector3 m_Offset; |
|
|
|
[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() |
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
void Update() |
|
|
|
void FixedUpdate() |
|
|
|
// gameObject.transform.position = target.position + offset;
|
|
|
|
gameObject.transform.position = newPosition; |
|
|
|
|
|
|
|
gameObject.transform.position = |
|
|
|
Vector3.SmoothDamp(transform.position, newPosition, ref m_CamVelocity, smoothingTime, Mathf.Infinity, |
|
|
|
Time.fixedDeltaTime); |
|
|
|
} |
|
|
|
} |
|
|
|
} |