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
24 REPLIES 24

vikneshtk
Honored Guest
I have tried Hands, Controllers and Hand anchors. Nothing worked as expected. Am I missing anything here?

AGTDigital
Explorer
if (OVRInput.Get(OVRInput.RawTouch.RIndexTrigger))
Are you sure this condition is passed when you press your button ?

If not, you should check which controller is connected :
Debug.Log(OVRInput.GetConnectedControllers());

vikneshtk
Honored Guest


if (OVRInput.Get(OVRInput.RawTouch.RIndexTrigger))
Are you sure this condition is passed when you press your button ?

If not, you should check which controller is connected :
Debug.Log(OVRInput.GetConnectedControllers());


Yes. The raycast works fine and the line renderer is ON whenever I touch the right trigger. You can see that in screenshots. I have also added a debug text, which assigned to a text object rendered on screen space camera. Only problem I face is the direction of the ray which is not aligned with the controller mesh/object.

vikneshtk
Honored Guest
Finally figured out the laser direction by changing the following line 
ShootLaserFromTargetPosition(/*cameraRig.rightHandAnchor.localPosition*/
ovrAvatar.HandRight.transform.position, Vector3.forward, laserMaxLength);
to
ShootLaserFromTargetPosition(/*cameraRig.rightHandAnchor.localPosition*/
ovrAvatar.HandRight.transform.position, ovrAvatar.HandRight.transform.forward, laserMaxLength);
Hope this will help someone !

lostJam
Honored Guest
this was so helpful wow thank you!!!! T^T