微信登录

Camera - FollowTarget.cs - 相机跟随

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class FollowTarget : MonoBehaviour {
  5. public Transform target;
  6. private Vector3 offset = new Vector3(0, 11.98111f, -14.10971f);
  7. private float smoothing = 2;
  8. // Update is called once per frame
  9. void Update () {
  10. Vector3 targetPosition = target.position + offset;
  11. transform.position = Vector3.Lerp(transform.position, targetPosition, smoothing * Time.deltaTime);
  12. transform.LookAt(target);
  13. }
  14. }