1 回答

TA貢獻(xiàn)1872條經(jīng)驗(yàn) 獲得超4個贊
您不應(yīng)該直接更改 VRCamera 的位置。
而是將父級添加GameObject到相機(jī)并通過例如更改該父級的位置(假設(shè)您的腳本已附加到相機(jī))
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 關(guān)注
- 206 瀏覽
添加回答
舉報