Skip to content

Instantly share code, notes, and snippets.

@314pies
Last active April 4, 2022 00:49
Show Gist options
  • Save 314pies/211661dc6485365bd0c71a2e430699d5 to your computer and use it in GitHub Desktop.
Save 314pies/211661dc6485365bd0c71a2e430699d5 to your computer and use it in GitHub Desktop.
public Transform handTransform;
void Update()
{
if (OVRInput.GetDown(OVRInput.Button.PrimaryHandTrigger))
{
//Do something when click the button on the VR controller
}
//Get thumbstick input
Vector2 primaryAxis = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick);
Vector2 secondaryAxis = OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick);
//Create raycast from VR hand (For virtual pointer)
RaycastHit hit;
if (Physics.Raycast(handTransform.position, handTransform.forward, out hit, 25.0f))
{
GameObject hittedGameObject = hit.transform.gameObject;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment