1 回答

TA貢獻1872條經驗 獲得超4個贊
您不應該直接更改 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 關注
- 208 瀏覽
添加回答
舉報