You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
586 B

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class DynamicCamera : MonoBehaviour
  5. {
  6. public GameObject target;
  7. public float camHeight;
  8. void Start()
  9. {
  10. }
  11. void Follow()
  12. {
  13. Vector3 tempDest = target.transform.position;
  14. tempDest -= transform.forward * camHeight;
  15. Vector3 destination = Vector3.Lerp(transform.position, tempDest, 10f * Time.deltaTime);
  16. transform.position = destination;
  17. }
  18. // Update is called once per frame
  19. void FixedUpdate()
  20. {
  21. Follow();
  22. }
  23. }