[SOLVED] How can I change the camera position in vr?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Spacekek

[SOLVED]

Hello, I’m trying to make a VR game with teleportation as the movement but I can’t seem to get the teleportation to work, right now I use a raycast to find where the player is aiming and then I change the position of the camera to the collisionpoint:

var camera = get_parent().get_node("Player_camera")
var collisionpoint = $teleport_ray.get_collision_point()
camera.position = collisionpoint

However this does not move my view in VR, however when I print the camera.position it is changed to where I was aiming.
Does anyone have any idea why the view is not changing while the camera position is?

I fixed it by changing the position of the XROrigin3D node instead and then recentering the view on the origin by doing XRServer.center_on_hmd(2, true) so it became:

var origin = get_parent()
var camera = get_parent().get_node("Player_camera")
var collisionpoint = $teleport_ray.get_collision_point()
origin.position = collisionpoint
XRServer.center_on_hmd(2, true)

Spacekek | 2023-07-07 18:04

Glad you have this working.

Ideally, you should add the above Comment as an Answer to this question and select it as Best. That way, in the main thread, the question will show up as 1) having an answer and 2) having an answer that solves the problem.

That’s the board’s official way of indicating [SOLVED] - rather than updating the questions title as you’ve done (though, nothing wrong with that in addition to the above).

jgodfrey | 2023-07-07 21:36