Unity 设置
实现代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraController : MonoBehaviour
{
public float Speed;
public Transform FollowTrans;
public Vector3 Offset;
// Start is called before the first frame update
void Start()
{
}
private void Awake()
{
Offset = transform.position - FollowTrans.position;
}
// Update is called once per frame
void LateUpdate()
{
if(FollowTrans != null)
{
transform.position = Vector3.Lerp(transform.position, (FollowTrans.position + Offset), Speed * Time.deltaTime);
}
}
}