参考链接:Unity3D整理——坐标系_LaiYizhou的博客-CSDN博客_unity 坐标系
获取摄像机坐标
public Transform Cam_transform;// 摄像机
private Vector3 Cam_pos0;// 摄像机坐标
Cam_transform = Camera.main.transform;
Cam_pos0 = Cam_transform.position;
根据游戏对象名字获取游戏对象
private Transform obj0;
obj1 = GameObject.Find("名字").transform;
摄像机平滑移动到某个特定位置
//摄像机组件
public Transform Cam_transform;
private Vector3 Cam_pos0;
public float smoothTime = 0.5F;
private Vector3 velocity = Vector3.zero;
//偏移量
private Vector3 offset = new Vector3(10, 10, -10);
Cam_transform = Camera.main.transform;
Cam_pos0 = Cam_transform.position; //保存摄像机初始坐标
// 摄像机回到自己的原始坐标
Cam_transform.position = Vector3.SmoothDamp(Cam_transform.position, Cam_pos0, ref velocity, smoothTime);
// 摄像机到固定某个坐标上
Cam_transform.position = Vector3.SmoothDamp(Cam_transform.position, 某个坐标值, ref velocity, smoothTime);
获取对象的相对坐标和绝对坐标
Vector3 posi = 对象.transform.position;
Vector3 localposi = 对象.transform.localPosition;