@@ -270,14 +270,8 @@ private Vector3 applyArmModel(Vector3 controllerPosition, Quaternion controllerR
270270
271271 bool xr_inited = false ;
272272
273- //public GameObject Head;
274273
275- private List < XRNodeState > mNodeStates = new List < XRNodeState > ( ) ;
276- private Vector3 mHeadPos ;
277- private Quaternion mHeadRot ;
278- private Vector3 mHandPos ;
279- private Quaternion mHandRot ;
280- //roblkw - mod
274+
281275 void InitXR ( )
282276 {
283277 xr_inited = true ;
@@ -290,16 +284,22 @@ void InitXR()
290284 }
291285 void Update ( )
292286 {
293- #if ! UNITY_EDITOR
294- return ;
295- #endif
296287 // Use Unity XR Input when enabled. When using WebXR, updates are performed onControllerUpdate.
297- //if (!XRDevice.isPresent) return;
288+ List < InputDevice > devices = new List < InputDevice > ( ) ;
289+ InputDevices . GetDevicesWithCharacteristics ( InputDeviceCharacteristics . HeadMounted , devices ) ;
290+ bool XRisPresent = devices . Count > 0 ;
291+ if ( ! XRisPresent ) return ;
298292
299293 if ( ! xr_inited ) InitXR ( ) ;
300294
301295 SetVisible ( true ) ;
302296
297+ List < XRNodeState > mNodeStates = new List < XRNodeState > ( ) ;
298+ Vector3 mHeadPos = Vector3 . zero ;
299+ Quaternion mHeadRot = Quaternion . identity ;
300+ Vector3 mHandPos = Vector3 . zero ;
301+ Quaternion mHandRot = Quaternion . identity ;
302+
303303 if ( this . hand == WebXRControllerHand . LEFT )
304304 handNode = XRNode . LeftHand ;
305305
@@ -338,15 +338,15 @@ void Update()
338338 if ( this . simulate3dof )
339339 {
340340 _t . localPosition = applyArmModel (
341- mHeadPos , //InputTracking.GetLocalPosition(XRNode.Head), // we use head position as origin
342- mHandRot , // InputTracking.GetLocalRotation(handNode);
343- mHeadRot ) ; //InputTracking.GetLocalRotation(XRNode.Head));
344- _t . localRotation = mHandRot ; // InputTracking.GetLocalRotation(handNode);
341+ mHeadPos , // we use head position as origin
342+ mHandRot ,
343+ mHeadRot ) ;
344+ _t . localRotation = mHandRot ;
345345 }
346346 else
347347 {
348- _t . localPosition = mHandPos ; // InputTracking.GetLocalPosition(handNode);
349- _t . localRotation = mHandRot ; // InputTracking.GetLocalRotation(handNode);
348+ _t . localPosition = mHandPos ;
349+ _t . localRotation = mHandRot ;
350350 }
351351
352352 foreach ( WebXRControllerInput input in inputMap . inputs )
0 commit comments