Skip to content

Instantly share code, notes, and snippets.

@314pies
Created April 1, 2022 08:58
Show Gist options
  • Save 314pies/33c3453bc6e6c6acffea6164401f8b7f to your computer and use it in GitHub Desktop.
Save 314pies/33c3453bc6e6c6acffea6164401f8b7f to your computer and use it in GitHub Desktop.
VRControllerInput.cs
public GameObject VP;
public GameObject Prefab;
public Transform hand;
GameObject theObj;
public float speed = 300.0f;
// Update is called once per frame
void Update()
{
//For getting button(s)
if (OVRInput.GetDown(OVRInput.Button.PrimaryHandTrigger))
{
theObj = Instantiate(Prefab);
theObj.transform.position = hand.position;
//theObj.transform.localScale = new Vector3(0.05f, 0.05f, 0.05f);
}
//For getting thumbstick
Vector2 primaryAxis = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick);
theObj.transform.Translate(primaryAxis * speed * Time.deltaTime);
RaycastHit hit;
if (Physics.Raycast(transform.position, transform.forward, out hit, 25.0f))
{
if (VP != null)
VP.transform.position = hit.point;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment