Hello everybody,
i’m developping a VR project in 2018 with the standard Oculus SDK (Utilities, Avatar,Platform).
i have a very simple scene with a table, some cube on , a mug and a gun.
When i play the game everything is ok in VR with the oculus, i see my hands and i can grab/throw objects.
But i need you cause when i grad the gun, its not in correct position in my VR hand.
i see the parameter in OVR grabbable “Snap position, Snap offset” but i dont understant how it work.
Can someone of you can explain me how to specify the orientation of the gun when i grad it ?
set up an empty gameobject at position (0,0,0) and rotation (0,0,0) in the unity scene. attach this as your snap offset transform in the ovr grabbable script. change the rotation or position values of this empty object by the amount you want the object to offset when you grab it.
I was struggling too to understand how it works. Now with the explanation above I think I’ve got it.
Honestly I think it’s not the best approach to have to pass a Transform to the grabber by the grabbable’s script since a Transform needs a GameObject to exist. But unfortunately it’s how it’s implemented here, I can change that, I know; but it doesn’t seem as it was one of the best ideas of how implementing that.
Our problem is even worse because the grabbable will use the global position and rotation from the transform passed as argument, when it would actually be better being able to attach a small GameObject to the grabbable’s gameObject and set its local position and rotation accordingly, exactly as a “offset” should work.
So here’s the deal: The grabber needs a Vector3 and a rotation. They’ve implemented the need of it by passing a Transform to the Grabber (which contains both) as an offset of the grabbable’s gameObject. Since the grabber will use the global position and rotation of this Transform and the fact that a Transform doesn’t exist without a GameObject, you need a brand new GameObject with its Transform set to the offset you want
Actually, forget what I said. This grabber transform thing is a really terrible implementation of the matter. It’s not at all done as players and developers would expect to use it. I will need to modify it to a more intuitive usability. I’ll try to post it here as soon as I get the time to make this change.
Hey, I’ve changed the original grabber script and I have something that is more intuitive for me (and probably everyone else too) than the original Oculus script. I see that some problems come from the fact this SDK is sometimes presented only as a demo and sometimes as a final product ready to use by developers, what gives us some headaches.
To the point:
Create an empty GameObject as a child of your grabbable object and adjust its position and rotation to place it where you want your hand to be.
Place this new GameObject in the Snap Offset slot of your grabbable GameObject.
It’s still very complicated to use because there’s no way of knowing what the transform will look like in game. Right now I’m just changing positions/rotation values randomly and hoping that when I see the result in-game it will line up. Typically it takes me an hour per grabbable object to guess the correct transform. It should really be a three minute job where you can visualize the grabbable transform rather than guessing in the dark.
I will just add this as a simple commentary. Regarding VR in Unity, since I discovered VRTK, I don’t really bother trying anything else anymore. The problem is just installing the correct VRTK version with the corresponding working SteamVR version, since they’re not necessarily the ones from Unity AssetStore. I got the correct ones looking at its Slack page. With that I could find many simplifications of what we usually try to implement for VR games, like snap on grab, teleportation, using grabbed items, etc
Thanks @edufireheart that worked for me
So confused why this hasnt been fixed in the current Oculus Integration 12.0 version still, it’s a critical bug that stops us from being able to use the OVRGrabbable scripts.
(My worry, is when/if I update my version of Oculus Integration, this issue will come back again… and if that is a year down the line, i may forget about this fix)
ok, this is how I fixed it now (without needing to change the script)
Remove local avatar from TrackingSpace
Drag the “CustomHandRight” and “CustomHandLeft” into the “LeftHandAnchor” and “RightHandAnchor”
In the components for the “CustomHandRight” and “CustomHandLeft”, tick the “Parent Held Object” (otherwise for me, the object will snap under the player and get stuck there… strange)
Use this as a guide:
from 0.25 he remotes the LocalAvatar, but read the comments from Valam and ShadowDog (Im just trying to figure out why my hands wont show, but other than that, it is working
edufireheart, thanks for the code snips. I found that for some reason the snap point was mirrored in X across the object’s pivot, but easy to compensate, saved me a ton of headaches. I also tried to override the OVRGrabber class, in hopes of not having to hack into OVR code, but ‘OVRGrabber is undefined’ for some reason. Hoping this is fixed officially, or XR Inputs or some toolkit will have it right.
This works pretty well! the only thing is that is snaps my weapon to hight. when u change the y of the grabber child object it doesnt change it when i build it or it just snaps it random somewhere else. U maybe have a idea how i can fix this?