How to freeze xrCamera position?

Before v6.0, modifying the position on engine.onEndFrameObservable can freeze the position of xrcamera, After updating to v6.0, this does not freeze the camera position very well, the xrcamera will respond when pushing to move. After testing, it is caused by the xr camera’s _deferOnly. So, how to do it in version 6.0?

can I ask what exactly are you trying to achieve? the XR camera should always move according to the headset’s position, otherwise it might cause issues to the person using your XR experience.

There are some places in my project that are similar to cutscenes. For example, when you reach the checkpoint, you will be fixed in that place, and a cow will appear behind you and eat you in its stomach. For a short time in the cow’s mouth, you will be fixed at a specific position (relative position) , and you can move freely after the transition is completed.
Because this is used in the classroom, students are operating in a fixed position, and the discomfort is acceptable(tested).

gosh, now I want to experience being eaten by a cow…

Anyhow - isn’t setting the position on each frame enough? Or does it not work as you expect?

Any method is acceptable as long as the camera is perfectly fixed. However, I have tried to change the position every frame in engine.runRenderLoop, sessionManager.onXRFrameObservable, scene.onBefore/AfterRenderObservable, and directly setInterval(***, 0), the xrcamera always shakes more or less when pushing to move,. So, other than changing position in engine.onEndFrameObservable when _deferOnly=false, I don’t know how to do it.

The XR camera was never expected to be used this way TBH. This is considered to be a bad practice in XR (even when eaten by a cow :slight_smile: ).

One way of achieving this is probably disabling the camera input that is in charge of the movement. I assume you use the movement extension and not the teleportation? Try detaching it when you don’t want the camera to move, and re-attaching it when you want movement as well. This way the deferred position will not be updated and you will be able to fix the position

ok, that does sound more reasonable, I’ll try,thanks

1 Like