cancel
Showing results for 
Search instead for 
Did you mean: 

[Integration Notice] Avatar Grab Unity sample available

mfmf
Oculus Staff
Hey folks: we've put together a sample of using the Avatar SDK with a few scripts to add object grab/throw functionality. I've attached it here. It requires the Oculus Utilities for Unity, and the Avatar SDK. 

This isn't the end of our hand samples, but I didn't want to leave you without at least a basic grab sample for too long. 

Known issue: it works in 5.5.0f3, but crashes in all 5.4.x versions of Unity I've tested so far. For now it's a 5.5-only sample. It doesn't rely on any 5.5-only functionality, however, so you should be able to use the scripts in 5.4 without a problem.

EDIT: updated to behave well with locomotion such as OVRPlayerController, 1/3/2017.
53 REPLIES 53

hisaitami
Honored Guest
I had the same problem with Unity v5.6.1f1, Oculus Utilities v1.15.0, OVRPlugin v1.14.1, SDK v1.15.0.

I found a workaround for it as follows.

index 0d38bde..74190a5 100644
--- a/Assets/OvrAvatar/Scripts/OvrAvatarLocalDriver.cs
+++ b/Assets/OvrAvatar/Scripts/OvrAvatarLocalDriver.cs
@@ -58,6 +58,24 @@ public class OvrAvatarLocalDriver : OvrAvatarDriver {
         };
     }

+    public bool MyGetCurrentPose(out PoseFrame pose)
+    {
+        pose = new PoseFrame
+        {
+            voiceAmplitude = voiceAmplitude,
+            headPosition = UnityEngine.VR.InputTracking.GetLocalPosition(UnityEngine.VR.VRNode.CenterEye),
+            headRotation = UnityEngine.VR.InputTracking.GetLocalRotation(UnityEngine.VR.VRNode.CenterEye),
+            handLeftPosition = OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch),
+            handLeftRotation = OVRInput.GetLocalControllerRotation(OVRInput.Controller.LTouch),
+            handRightPosition = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch),
+            handRightRotation = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch),
+            controllerLeftPose = GetControllerPose(OVRInput.Controller.LTouch),
+            controllerRightPose = GetControllerPose(OVRInput.Controller.RTouch),
+        };
+        return true;
+    }

and edit Grabber.cs
105:                ((OvrAvatarLocalDriver)m_avatar.Driver).MyGetCurrentPose(out frame);

SilentR3
Honored Guest
Getting the same issue with Unity 5.6 - grabbing does not work and the cubes are not shading properly. Bumping in hopes of a fix

jyfchen57
Explorer

pjenness said:



mfmf said:


It's jittery because you're updating the object's position at a different frame rate than that of the HMD or of the hand. With that exact approach, it's going to be jittery.

There are many other approaches. Parenting is a simple one. If you need solid physics, you can separate the visual mesh and rigid body, and parent the visual mesh while updating the rigid body at a lower frame rate.



I managed to have the best of both worlds with a bit of a hack:
https://forums.oculus.com/community/discussion/comment/478680/#Comment_478680

The visual renderers become parented so looks smooth, and the collision objects remain outside, and use rigidbody movement to do correct collision detection.
So far has been working well.

-P



I tried this solution and I'm still experiencing jitter. I pause in unity and the colliders are unparented while everything else is parented under a grabber object. What could be the problem?

Edit: I just saw that the grabber is still using a rigidbody to move around, so attaching the object to it will still look jittery. Attaching the objects to the hands instead did the trick. Whoops!


However, the physics don't work very well now.

infinnite
Honored Guest
IT SAYS THERE ARE multiple transform components