Hi2.,
How do i know via script which headset is currently being used by the player at the beginning of the app ?
for example if the player use HTC Vive, Oculus Rift, Oculus Quest or even HP Reverb ?
I use XR Plugin management with Oculus and OpenVR Loader
I also have SteamVR installed in my Asset. But no Oculus Integration package
There really isnât a way to do that. The purpose behind XR SDK is to abstract the differences out so you donât have to worry about the hardware in general.
That said that are a couple ways you may be able to figure this out:
Get the active loader from XR Plug-in Management and try casting it to a loader type for one of the target platforms. Youâll need to know the loader type AND have that type compiled into your program for this to work.
You can look at the information for the hardware provided by the XR Input system. The propertied in InputDevice are probably the best way to get that. Make note that the information presented here is information we get directly from the system/hardware and you may need to translate it to something that you can use.
and maybe a bit of beginner question:
How do i get the object name that i currently grab with XR Controller ?
i read the documentation but perhaps i miss something
The XR Controller component just provides the input to an Interactor component. You probably have an XR Ray Interactor or XR Direct Interactor on the same GameObject as the XR Controller, and itâs those Interactor components that actually do the grabbing of an XR Grab Interactable. They do so by âselectingâ an Interactable.
So if you want to get the name of the object you are grabbing, you would need a reference to the Interactor and use the selectTarget property, and then name.
Hi Christ., Sorry for re-opening this forum.
However, how do i temporarily disable the XRGrabInteractable? So that no one can grab that object?
I have tried disabling the Collider, clearing the Colliders in the XRGrabInteractable and freezing the position on the Rigidbody.
but none seems to works 100%.
The collider disabling kinda works., but if i have my hand (just hovering, without grabbing) and then i disable the collider
I still able to grab the object. However, if i move my hand outside the gameObject, then it will work.
You can disable the XRGrabInteractable by setting enabled false. That will unregister it from the XRInteractionManager so it wonât be able to be hovered or selected, and even cancel out any existing hover or selection. Setting enabled back to true will re-register it again. You could also clear out its interactionLayerMask, and then restore the value when you want to re-enable it.
To explain why disabling the Collider doesnât work in that case, Direct Interactor utilizes OnTriggerExit to detect when a Collider leaves it, but that method doesnât get called when the Collider is disabled instead.
I get that abstraction is generally a good thing. The problem, a big problem for me, is I want to display the matching hardware in-scene. If they are on Quest 1, I want dark Touch controller models. Quest 2 has white ones, etc. And if mulitplayer, Iâd like the remote avatars to be holding their respective controllers, wearing their particular headsets. Iâm very surprised there isnât just one âdevice IDâ field that says âViveProâ or âOculusQuest1â or something like that. Are you sure there is no way to do this? I would hate to go back to the old system(s)
Except that this stops developers from showing the right controllers for their headset - which is kind of important for tutorials and to show people where things like buttons are (when, for example, their real world view of the controller buttons is obstructed by a headset).
Unless of course OpenXR and Unity isnât meant to be used for training / teaching / education / industrial use etc. In which case using abstract buttons that donât match the real world is perfectly fine.