Files
daluandou/Assets/Script/CameraFollow.cs
T
2026-08-09 23:42:37 +08:00

23 lines
780 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraFollow : MonoBehaviour
{
public Transform target; // 角色的Transform组件
public Vector3 offset; // 摄像机相对于角色的偏移量
public float smoothSpeed = 0.125f; // 摄像机移动的平滑速度
void LateUpdate()
{
// // 计算摄像机应该到达的目标位置
// Vector3 desiredPosition = target.position + offset;
// // 使用Lerp方法平滑移动摄像机到目标位置
// Vector3 smoothedPosition = Vector3.Lerp(transform.position, desiredPosition, smoothSpeed);
// transform.position = smoothedPosition;
// // 让摄像机始终看向角色
// transform.LookAt(target);
}
}