@@ -22,6 +22,7 @@ public class ControllerInteraction : MonoBehaviour
2222
2323 public Transform handJointPrefab ;
2424 private bool handJointsVisible = false ;
25+ [ SerializeField ] private bool useCollidersForHandJoints = true ;
2526
2627 [ SerializeField ] private bool useInputProfile = true ;
2728
@@ -155,6 +156,37 @@ private void OnTriggerExit(Collider other)
155156 contactRigidBodies . Remove ( other . gameObject . GetComponent < Rigidbody > ( ) ) ;
156157 }
157158
159+ public void SetUseCollidersForHandJoints ( bool value )
160+ {
161+ useCollidersForHandJoints = value ;
162+ for ( int i = 0 ; i <= ( int ) WebXRHandJoint . pinky_finger_tip ; i ++ )
163+ {
164+ if ( handJoints . ContainsKey ( i ) )
165+ {
166+ var collider = handJoints [ i ] . GetComponent < Collider > ( ) ;
167+ if ( collider != null )
168+ {
169+ collider . enabled = useCollidersForHandJoints ;
170+ }
171+ }
172+ #if WEBXR_INPUT_PROFILES
173+ if ( handModelJoints . ContainsKey ( i ) )
174+ {
175+ var collider = handModelJoints [ i ] . GetComponent < Collider > ( ) ;
176+ if ( collider != null )
177+ {
178+ collider . enabled = useCollidersForHandJoints ;
179+ }
180+ }
181+ #endif
182+ }
183+ }
184+
185+ public bool GetUseCollidersForHandJoints ( )
186+ {
187+ return useCollidersForHandJoints ;
188+ }
189+
158190 public void SetUseInputProfile ( bool value )
159191 {
160192 useInputProfile = value ;
@@ -290,6 +322,11 @@ private void OnHandUpdate(WebXRHandData handData)
290322 {
291323 clone . localScale = new Vector3 ( 0.005f , 0.005f , 0.005f ) ;
292324 }
325+ var collider = clone . GetComponent < Collider > ( ) ;
326+ if ( collider != null )
327+ {
328+ collider . enabled = useCollidersForHandJoints ;
329+ }
293330 handJoints . Add ( i , clone ) ;
294331 handJointsVisuals [ i ] = clone . gameObject ;
295332 }
@@ -413,9 +450,12 @@ private void HandleHandModelLoaded(bool success)
413450 if ( handJoints . ContainsKey ( i ) )
414451 {
415452 handModelJoints [ i ] . SetPositionAndRotation ( handJoints [ i ] . position , handJoints [ i ] . rotation ) ;
416- var collider = handModelJoints [ i ] . gameObject . AddComponent < SphereCollider > ( ) ;
417- collider . radius = handJoints [ i ] . localScale . x ;
418- collider . isTrigger = true ;
453+ if ( useCollidersForHandJoints )
454+ {
455+ var collider = handModelJoints [ i ] . gameObject . AddComponent < SphereCollider > ( ) ;
456+ collider . radius = handJoints [ i ] . localScale . x ;
457+ collider . isTrigger = true ;
458+ }
419459 }
420460 }
421461 if ( handJointsVisible )
0 commit comments