unity3d:向量计算,摄像机与目标位置

目标与摄像头,摄像头重新出现在两者连线方向的距离目标10m处

            Vector3 oldPos = transform.position;
            Vector3 dir = oldPos - pos;
            Vector3 newPos = pos + dir.normalized * 10;
            transform.DOMove(newPos, 0.5f);

实现摄像头lookat 目标效果,并相距10m

            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);

你可能感兴趣的:(Unity3D实用技术笔记,unity3d物理计算)