//==========================
// - FileName: FollowTarget.cs
// - Created: true.
// - CreateTime: 2020/07/22 15:53:19

// - Region: China WUHAN
// - Description: 相机跟随脚本
//==========================
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FollowTarget : MonoBehaviour
{
//跟随目标
public Transform target;
//偏移位置
public Vector3 offset = new Vector3(0, 6.663081f, -4.835666f);
public float smoothing = 2f;

void Update()
{
Follow();
}

private void Follow()
{
Vector3 targetPosition = target.position + offset;
transform.position = Vector3.Lerp(transform.position, targetPosition, smoothing * Time.deltaTime);
transform.LookAt(target.position);
}
}