I've been trying to implement a locomotion movement system for my VR project, folloeing the official documentation (https://docs.godotengine.org/en/3.1/tutorials/vr/vr_starter_tutorial.html).
I have a ARVRPlayer-Node, that extends ARVROrigin, and has the following code in its process-function:
var rotate_vector = get_rotate_angle()
rotate_y(rotate_vector * rotation_speed)
var input_vector = get_left_input_vector()
if input_vector.length() < thumbstick_treshold:
input_vector = Vector2(0, 0)
else:
input_vector = input_vector.normalized()
var forward_direction = $ARVRCamera.global_transform.basis.z.normalized()
var right_direction = $ARVRCamera.global_transform.basis.x.normalized()
var movement = (forward_direction * input_vector.y) + (right_direction * input_vector.x)
movement.y = 0
if movement.length() > 0:
translate(movement * delta * movement_speed)
WebSocketInterface.get_node("PlayerInterface").player_update("body", transform.origin, rotation)
As the code suggests, the ARVRCamera is a child of the ARVRPlayer-Node.
Unfortunetly, the movement does not work the way I imagined it. When I rotate the player in different directions, it does not move "forward" anymore when pressing "W" or pushing the joystick forward. The movement directions wonkily changed depending on the player rotation. Can anybody tell me what I did wrong?