在角色设置两个挂载点,第一人称时,相机放在eys上面,切换第三人称时,放置到3rd节点上面,调整节点位置,达到期望效果
代码
void ThirdView()
{
Debug.Log("切换到第三人称");
camera.SetParent(thirdParent);
camera.transform.localPosition = Vector3.zero;
camera.transform.localRotation = Quaternion.identity;
}
void OneView()
{
Debug.Log("切换到第1人称");
camera.SetParent(OneParent);
camera.transform.localPosition = Vector3.zero;
camera.transform.localRotation = Quaternion.identity;
}