Move Map with Oculus Joysticks

Hello devs, what I want to do is use the left joystick on the oculus Q2 to move the 3d map around, and use the right joystick to handle the zoom. I have no idea where to start. I see some suggestions using CesiumJS, but nothing for Unity. Any tips on where to begin would be appreciated! Thanks in advance.

Edit: I understand that I can move the camera around with the joysticks, but it doesn’t feel like the best practice.

Hi @bauervision,

If you don’t want the camera itself to move, then you’d have to write a script that changes the transform and scale of the CesiumGeoreference based on joystick input. For example, I imagine zooming in and out with the right joystick involves checking its direction, then scaling up or down. Similarly, check the left joystick’s input, then do something like Transform.Translate (docs) based on the direction you want to move.

There’s also a uniform scale property that you can set on the CesiumGeoreference itself – it has more precision than Unity’s scale, so it may be better to use.

Thank you @janine, would you consider transforming the CesiumGeoreference as being a best practice, or simply moving the camera?

That really depends on your application. If it makes sense for the user to be moving around the globe, then move the camera. Otherwise, if the globe should move around the user, then move the CesiumGeoreference. If there are other elements in your application, then think about whether those should stay put or whether the user should move around those as well.

1 Like

Understood thank you.

Edit: I was able to get a great working solution by simply disabling the Character Controller on the XR Origin in the VR sample for Denver.

1 Like

If in my application I decide to always move the CesiumGeoreference, keeping the camera within a few meters of the origin, does that negate the need for origin shifting?

Hi @WooorldPaul,

Yes, CesiumOriginShift basically moves the CesiumGeoreference every frame so that it is at the Unity origin. It sounds like you’re implementing custom origin shifting behavior, so there’s no need to use CesiumOriginShift along with it.