cancel
Showing results for 
Search instead for 
Did you mean: 

Add ray cast from the hand in Unity

alexvilch
Protege
Simple question: for Oculus Avatar SDK how do I add the ray coming from the hand ( left or right ) if I take Avatar SDK for Oculus Unity "Controllers" scene, just simple hands.
In order to interact with other objects I would need to add event systems and canvas found examples for those but unable to find a clear explanation how to add this to Avatar hands just want to cast the ray from the hand. I'm using the latest Avatar SDK and the latest Unity 2017.3.f1
 Thank you,
Alex
1 ACCEPTED SOLUTION

Accepted Solutions

alexvilch
Protege
Yes, I did. Just add vizualizer object with the ray and it started casting the ray from "active" hand: switching the trigger on the touch controller shifts the ray from one hand to another. None of the functions mentioned above working. You could copy it from this example:


I could not figure out how to cast the ray from the index finger like in Dash home in my case its coming from the base of the hand: from my understanding this requires making changes to the Animation of the hands.

Do not bother about those Transform functions and etc. it's simply not working.

Alex

View solution in original post

24 REPLIES 24

MikeF
Trustee

alexvilch
Protege
Thank you, Mike.
From this doc:

You can specify the hand and joint you want and then use GetHandTransform() to get its transform.

public Transform GetHandTransform(HandType hand, HandJoint joint)Is 
How do I cast the ray from the hand ? Is there any practical example ?
Alex

MikeF
Trustee
So what you'l want to do is wait until the avatar is initialized fully, then call Transform raycastOrigin = GetHandTransform(HandType.Left(or right), Handjoint.HandBase).

Then you can reference that transform.position and transform.forward for any raycasting needs

alexvilch
Protege
Mike,
Thanks again but I'm new in Avatar/Unity. I wish they would just add a clear example for this one like for grabable objects.
In Oculus Avatar latest example where it would be the best place to add this code ? Also this would do the raycasting but how I would specify the distance of the ray and its properties ?

 Thank you for your help,

Alex

ProtopottyGames
Explorer
I was just by chance reading this thread a couple of days ago that seems like it might be similar to your problem. Might give it a look: 
https://forum.unity.com/threads/unity-5-2-vr-raycast-solved.361211/
(Make sure to read the whole thing as there's a bit of back and forth prior to the OP solving his problem)
Also (as always...lol) I highly recommend checking out VRTK. Especially if you are new to coding, or just VR dev in Unity in general. :smile:

VRTK:
https://vrtoolkit.readme.io

Ross_Beef
Heroic Explorer
Hey all, late to the party but had a similar question from another developer and thought this alternative function might be worth sharing. It looks like it's not included in our docs, so will make sure it's added.

This should be accessible from Unity Avatars integration:
public void GetPointingDirection(HandType hand, ref Vector3 forward, ref Vector3 up)

Where forward = finger point and up = thumb point direction

alexvilch
Protege
jimthegreen: According VRTK  in the tutorial for “Getting started with Oculus Avatar” they are currently not supporting Avatar handmodel. So I have to use the controllers from Avatar but not able to use hands just like in Oculus dash home where the Ray is coming out from my hand.
Ross_Beef: is there any practical example in Unity to add the ray cast coming out from my my hand in Avatar SDK ?

 Thank you all for your help,
Alex

ProtopottyGames
Explorer
Ah yes that's correct alexvilch, Apparently it doesn't currently support io for the Oculus hand. my bad. :sweat_smile:

Malicore
Protege

alexvilch said:

jimthegreen: According VRTK  in the tutorial for “Getting started with Oculus Avatar” they are currently not supporting Avatar handmodel. So I have to use the controllers from Avatar but not able to use hands just like in Oculus dash home where the Ray is coming out from my hand.
Ross_Beef: is there any practical example in Unity to add the ray cast coming out from my my hand in Avatar SDK ?

 Thank you all for your help,
Alex


I also tried implementing VRTK but decided to switch back due to the lack of handmodel support, and the fact that the developer is slowly walking away from the SDK and plans to release one final update.