CameraFollow.cs 539 B

1234567891011121314151617181920
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class CameraFollow : MonoBehaviour
  5. {
  6. // Start is called before the first frame update
  7. public Transform target;
  8. public float offsetY;
  9. void LateUpdate ()
  10. {
  11. if (target != null) {
  12. Vector3 targetPoint = target.position;
  13. targetPoint.y += offsetY;
  14. //targetPoint.z += 7f;
  15. transform.position = Vector3.Lerp (transform.position, targetPoint, Time.deltaTime * 5f);
  16. }
  17. }
  18. }