1 回答
TA贡献1872条经验 获得超3个赞
您不应该直接更改 VRCamera 的位置。
而是将父级添加GameObject到相机并通过例如更改该父级的位置(假设您的脚本已附加到相机)
public class ResetPosition : MonoBehaviour
{
public Vector3 resetPosition;
private void Awake()
{
// create a new object and make it parent of this object
var parent = new GameObject("CameraParent").transform;
transform.SetParent(parent);
}
// You should use LateUpdate
// because afaik the oculus position is updated in the normal
// Update so you are sure it is already done for this frame
private void LateUpdate()
{
if (Input.GetKeyDown(KeyCode.Space))
{
Debug.Log("pressed");
// reset parent objects position
transform.parent.position = resetPosition - transform.position;
}
}
}
- 1 回答
- 0 关注
- 158 浏览
添加回答
举报