目标与摄像头,摄像头重新出现在两者连线方向的距离目标10m处
代码语言:javascript复制 Vector3 oldPos = transform.position;
Vector3 dir = oldPos - pos;
Vector3 newPos = pos dir.normalized * 10;
transform.DOMove(newPos, 0.5f);
实现摄像头lookat 目标效果,并相距10m
代码语言:javascript复制 Vector3 camRotation = transform.eulerAngles;
Quaternion rotation = Quaternion.Euler(camRotation.x, camRotation.y, 0);
Vector3 negDistance = new Vector3(0.0f, 0.0f, -10);
Vector3 position = rotation * negDistance pos;
transform.DOMove(position, 0.5f);