04-10-2018 12:38 PM
Solved! Go to Solution.
04-25-2018 04:15 PM
04-25-2018 04:26 PM
04-26-2018 12:53 PM
04-28-2018 01:43 PM
05-14-2018 02:26 PM
Transform GetHandTransform(HandType hand, HandJoint joint)Working without this, I've tried to replace Handjoint.Handbase with any values below, still the ray is coming out from the middle of the hand, not like in Oculus Dash home.
07-25-2018 04:32 PM
07-25-2018 07:07 PM
07-26-2018 07:13 AM
08-28-2019 06:30 AM
using UnityEngine;
using UnityEngine.UI;
public class CustomLaserPointer : MonoBehaviour
{
public LineRenderer laserLineRenderer;
public float laserWidth = 0.1f;
public float laserMaxLength = 5f;
OvrAvatar ovrAvatar;
//OVRCameraRig cameraRig;
public Text text;
void Start()
{
Vector3[] initLaserPositions = new Vector3[2] { Vector3.zero, Vector3.zero };
laserLineRenderer.SetPositions(initLaserPositions);
laserLineRenderer.SetWidth(laserWidth, laserWidth);
//cameraRig = FindObjectOfType<OVRCameraRig>();
ovrAvatar = FindObjectOfType<OvrAvatar>();
}
void Update()
{
if (OVRInput.Get(OVRInput.RawTouch.RIndexTrigger))
{
ShootLaserFromTargetPosition(/*cameraRig.rightHandAnchor.localPosition*/
ovrAvatar.HandRight.transform.position, Vector3.forward, laserMaxLength);
text.text = "laser pointer triggered"; //debug text
laserLineRenderer.enabled = true;
}
else
{
text.text = "";
laserLineRenderer.enabled = false;
}
}
void ShootLaserFromTargetPosition(Vector3 targetPosition, Vector3 direction, float length)
{
Ray ray = new Ray(targetPosition, direction);
Vector3 endPosition = targetPosition + (length * direction);
if (Physics.Raycast(ray, out RaycastHit raycastHit, length))
{
endPosition = raycastHit.point;
}
laserLineRenderer.SetPosition(0, targetPosition);
laserLineRenderer.SetPosition(1, endPosition);
}
}
08-28-2019 06:30 AM