public class CameraFollow : MonoBehaviour
{
public Transform target;
public float smoothing = 5f;
Vector3 offset =new Vector3(1,15,-22);
Transform mTrans;
void Start ()
{
mTrans = transform;
mTrans.eulerAngles = new Vector3(30,0,0);
}
void FixedUpdate ()
{
Vector3 targetCamPos = target.position + offset;
mTrans.position = Vector3.Lerp (transform.position, targetCamPos, smoothing * Time.deltaTime);
}
}
简单相机跟随
最新推荐文章于 2025-04-05 19:40:18 发布
这篇博客介绍了如何使用Unity中的CameraFollow脚本实现对象跟随目标位置,通过Vector3.Lerp平滑地移动相机,并设置了smoothing参数和offset偏移量。
1万+

被折叠的 条评论
为什么被折叠?



