Created
April 1, 2022 08:58
-
-
Save 314pies/33c3453bc6e6c6acffea6164401f8b7f to your computer and use it in GitHub Desktop.
VRControllerInput.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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