- Transform m_Rounder = Camera.main.transform;
- Transform m_Center = m_TargetXingqiu.transform;
- //当前触摸的坐标与上一个触摸坐标的偏移量
- Vector2 offsetPos = m_TouchCurPos - m_TouchPrePos; //围绕半径
- float radius = (m_Rounder.position - m_Center.position).magnitude;
- //相机到目标的向量
- Vector3 camRelativeToTarget = Vector3.Normalize(m_Rounder.position - m_Center.position);
- //触摸为照相机坐标,将此坐标转为世界坐标
- Vector3 touchCurWorldPos = m_Rounder.localToWorldMatrix.MultiplyPoint(new Vector3(m_TouchCurPos.x, m_TouchCurPos.y, 0f));
- Vector3 touchPreWorldPos = m_Rounder.localToWorldMatrix.MultiplyPoint(new Vector3(m_TouchPrePos.x, m_TouchPrePos.y, 0f));
- //触摸方向向量转世界向量
- Vector3 touchVec = touchCurWorldPos - touchPreWorldPos;
- //围绕的旋转轴
- Vector3 roundAxis = Vector3.Cross(touchVec, camRelativeToTarget);
- m_Rounder.RotateAround (m_Center.position, Vector3.Normalize(roundAxis), roundAxis.magnitude*0.1f);
相机围绕目标旋转
最新推荐文章于 2024-04-19 14:28:16 发布