给相机挂载脚本,通过计算相机与主角之间的偏移量来控制。
public Transform palyerTransform;
public Vector3 offest;
void Start()
{
offest = transform.position - palyerTransform.position;
}
void Update()
{
transform.position = offest + palyerTransform.position;
}
![](https://img-blog.csdnimg.cn/img_convert/3bbaeaa54ece1c9fc3ac72d553cc505c.png)