In my project the player is sitting on a chair in a cockpit and it is not inteded that the player can move around. So my question is: Is there a way to limit the player's movement either by setting an area he cannot leave or by forcing 3DOF (as it would be when using the Oculus Go for example)
Limiting the dimensions of freedom for GodotVR
Even if you can, I don't think it's a good idea. It would be very disturbing to move and not see the feedback from movement. More than likely the cockpit/model being an enclosed space will cause players to take off the headset before moving from the seat which should probably be good enough.
- Edited
What I might recommend doing in this case is having an Area that can detect whether the player is outside of the cockpit and then somehow informing the user that they have stepped outside of the bounds, maybe turning everything outside of the cockpit black and disabling player interaction until the player re-enters the cockpit.
That way, you can still give the player some freedom to move around, but without having to necessarily undo every movement.
That said, I believe the following code should remove the ability for the player to move around the scene in VR (untested):
extends ARVROrigin
var arvr_camera = null
export (Vector3) var additional_offset = Vector3.ZERO
var _last_camera_offset = Vector3.ZERO
func _ready():
arvr_camera = get_node("ARVRCamera")
func _process(_delta):
# Move the ARVR node back into position
translation.x += _last_camera_offset.x
translation.z += _last_camera_offset.z
# Get the new camera offset
_last_camera_offset = arvr_camera.translation + additional_offset
# Move this node in the opposite position as the translation of the
# ARVRCamera node, effectively canceling it.
# However, we only want to do this on the X and Z axes, as otherwise
# player height will not be taken into account
translation.x -= _last_camera_offset.x
translation.z -= _last_camera_offset.z
Though, as Megalomaniak mentioned, it may be very disorienting to not be able to move around the scene when your body is moving. Some players may get motion sick, which could be problematic.
Also, welcome to the forums!
Thanks for the warm welcome and the quick replies to my question.
I think stopping player interactions and/or turning off the environment might be a really a good idea. I'm gonna give it a try.