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

ivialb21
Honored Guest
Works perfectly except for the datarates not matching. Clicks don't synchronize with the grab location perceived.

clint205
Explorer
Thanks so much for this!  What I am really also looking for is how to have the hand also grip the object correctly like in the Oculus First Contact tutorial.  I'm assuming a custom grip has to be made and I believe I have figured out how to make custom poses, I just need to know how to get it called when the gripping of an object occurs.

dvir
Explorer
@clint205: the best place for that would probably be in the Grabbable script, in GrabBegin and GrabEnd. You'll want to get a reference to the LocalAvatar's OvrAvatar component at that point, and then set avatar.RightHandCustomPose to the transform you made through this example: https://developer3.oculus.com/documentation/avatarsdk/latest/concepts/avatars-sdk-unity/#avatars-sdk...

For a really, really quick hack, drag the GameObject prefab you made from that tutorial to the Resources folder, call it for example "customHandPose", and then put this at the end of your Grabbable.GrabBegin call:

  GameObject.FindObjectOfType<OvrAvatar>().RightHandCustomPose = ((GameObject)Resources.Load("customHandPose")).transform;

Let me know if that is still not clear 🙂

KevinLongtime
Heroic Explorer
Having a problem with grabbed objects losing parenting with artificial turning. Issue Occurs at 0:18

https://www.youtube.com/watch?v=j0teT5IL3E8

6072tiy466fm.jpg

Anything I'm overlooking? Tried parenting the avatar system to a bunch of different things and it doesn't solve this yet. Not only does it mess up an object you current have held but it messed up the detection for picking up other objects in the scene unless you resent orientation.

Dorako
Explorer
@Codexus Yeah I'm not sure upping the physics frequency that much and also tying it to HMD refresh rate is a good thing.

fancyfennec
Explorer
Why is it so jittery when you hold an object? This should work even if Interpolate is set to none. I have a touch project with grab that I made from Ben Roberts' YouTube tutorial, and that works without the jitter. There has to be another solution than changing the Physics time step.

pjenness
Rising Star

Rave185 said:



Still having trouble getting custom player avatars working though. The generic fallback avatar works, but no custom ones.








Try starting with the OVR avatar disabled, use another class to poll the user ID of the player

public string m_OVRappID = "";
public User m_OVRuser = null;
public ulong m_OVRuserID = 0;


void Awake ()
{
Core.Initialize (m_OVRappID);
doEntitlementCheck ();
Users.GetLoggedInUser ().OnComplete (GetLoggedInUserCallback);
}


private void GetLoggedInUserCallback (Message msg)
{
if (!msg.IsError) {
m_OVRuser = msg.GetUser ();
m_OVRuserID = m_OVRuser.OculusID;
}
}





Then on your ovrAvatar base character   (in my case I have a link to it m_OVRavatar)



public OvrAvatar m_OVRavatar = null;


void Awake ()
    {

        OvrAvatar ovrAvtr = this.GetComponent<OvrAvatar> ();
        if (ovrAvtr) {
           m_OVRavatar = ovrAvtr;
        }
    }



once you have the UserID from earlier, pass it across and activate the Avatar. If I do it in this order it works,
If I start already activated I get the dummy as the userID is 0. And I cant work out how to force a refresh if I change the userID



m_OVRavatar.oculusUserID = m_myGameManager.m_myAppManager.m_OVRuserID;
m_OVRavatar.enabled = true;



Drift VFX Visual, Virtual , Vertical Want 970GTX on Macbook for good FPS? https://forums.oculus.com/viewtopic.php?f=26&t=17349

pjenness
Rising Star

Im having problems with the grabbers not sticking aligning to the touch hands.

If I use the demo scene it seems to work fine. Ive extract the avatarWithGrab as a prefab and bring it into my game. Parented under a player controller heirarchy. Now the grabbers dont align.

Im not sure if its heirarchy, or that Im useing "Eye Level" not :"Floor Level"   or the order I am activating things. But I cant get the grabbers to be in the correct hand positions.

Update: Discovered that the rotation of a parent (ie the player controller) effects the "grabbers". At 0,0,0 they attach fine, once start rotating (say round Y) they mis-align.
Not sure how to counteract that.

OVRS Devs:   If you open the sample grab scene and play it works. Then if you grab the top of the ovrAvatar heirarch and rotate 90o you can see the grabbers do not rotate accordingly. They are are only usingthe local tracking info of the TrackingSpace , we need to add any additional heirarchy rotations on top. I think this should be a default check box, unless ther is already a way to do it?

EDIT:  See next post for the line change


-P




Drift VFX Visual, Virtual , Vertical Want 970GTX on Macbook for good FPS? https://forums.oculus.com/viewtopic.php?f=26&t=17349

pjenness
Rising Star
I got it.

Change the line in grabber.cs FixedUpdate to

GetComponent<Rigidbody> ().MovePosition (m_parentTransform.rotation * ((handPos + m_anchorOffsetPosition)) + m_parentTransform.position);

GetComponent<Rigidbody> ().MoveRotation (m_parentTransform.rotation * (handRot * m_anchorOffsetRotation));


Drift VFX Visual, Virtual , Vertical Want 970GTX on Macbook for good FPS? https://forums.oculus.com/viewtopic.php?f=26&t=17349

pjenness
Rising Star
Is it just me, or has the original functionality of OVRTouch gone where a fist or pointed finger generated collision detection?
I used to be able to punch rigid bodies, but not with the new Avatar based hands.


Also something has changed tht breaks the mapping from mechanim IK hands to these new hands. THey previously worked well that you map the ik target of mechanim hands to the "Hand" from OVRtouch, but this doesnt work so well anymore. I have to dig 3 layers deep to find the hands:b_l_hand joint, to get pos. Rotation is next. Prob similar issue to above. (Vector math  urgh    :s )


-P


Drift VFX Visual, Virtual , Vertical Want 970GTX on Macbook for good FPS? https://forums.oculus.com/viewtopic.php?f=26&t=17349