How to set local position on VR camera?

I am creating a VR experience and would like to be able to reset the VR root position (the parent of the VR camera) to the current position of the camera, on demand.

My thought for how to do this was to move the root position to the current camera position, and then essentially zero out the XZ of the camera’s local position. From the point of view of the camera, no visible change will occur, just the root will now be directly under the camera.

The code I’m trying for this goes like this:

CameraController.prototype.onKeyDown = function(event){
    var camPos = this.camera.getPosition();
    var camLocalPos = this.camera.getLocalPosition();
    var rootPos = this.entity.getPosition();
    
    if (event.key === pc.KEY_F){
        this.entity.rigidbody.teleport(camPos.x, rootPos.y, camPos.z);
        this.camera.setLocalPosition(0, camLocalPos.y, 0);
    }
};

The teleport works fine, but I can’t seem to alter the local position of the camera. It just doesn’t do anything. What am I doing wrong?

I may need to double check on this but it’s most likely because the local position of the VR camera is tracking the VR headset (6DoF) in its local space.

What you will need to do for teleport is to move the position of the parent not to where the user clicked, but taking into the account the current local position of the VR camera.

Eg if the local position of the VR camera is (0,0,1) and the teleport target is at (0,0,20). The parent position will be at moved to (0,0,19)

The problem is that I’m trying to create a physics-based VR player. So the VR root has a collision/rigid body setup, and movement around the scene can be done using controls that essentially add forces to the rigid body.
For a seated player, this is fine, because the camera will always remain close enough to the collision component. However, a room scale player might deviate from the root position. Suppose the player steps backwards from the root position by one metre, and then uses controls to move forward and collides with a wall. Since the collision component is now one metre ahead of them, they will appear to hit the wall sooner than they should.
That’s why my intended solution was to realign the root (which has the collision component) with the camera position before adding forces and moving the player. This is kinda how I would do it in Unreal.
I don’t understand why it’s not possible to alter the position of the VR camera though. I know in principle you don’t want to start messing with a VR camera because of motion sickness etc. but it’s useful for instances like this where an ‘under the hood’ adjustment needs to be made.
Perhaps there is a better way to create a VR player which uses collision/forces?

When you say VR root, do you mean the camera parent entity?

You can’t move the VR camera entity because it maps 1 to 1 with the local position of the headset.

In the real world, imagine you have a point of reference in the center of the room and that’s where you start off standing. That’s basically the parent of the VR camera entity.

The headset is the VR camera entity and it’s parent is that point of reference.

As you move around the room, the offset position between the headset and the point of reference is the local position of the VR camera entity.

The way I would do this is to have the player rigid body as kinematic (collisions, external forces don’t affect it) and have it separate from the VR camera entity. It would just follow it in a postUpdate call or similar.

That way, you can move the VR camera by its parent
entity without having to worry about the physics simulation overwriting any game logic positional changes.