How can I add OVRCameraRig in here?

Hi forum. Im trying to post it here.

I have made this script with a little inspiration from another. I am trying to make a graphic raycaster from the OVRCameraRig, so the ray comes from the VR headset in Unity.

How can I do that? Please bear with me, I am not a pro at programming :slight_smile:

Here is my code:

I guess I just cant write OVRCameraRig, otherwise it would probably work.

How can I implement OVRCameraRig without altering the code to much?

Thanks

You need to have a reference to your Camera Rig
Something like :

public GameObject cameraRig;

Debug.DrawRay(cameraRig.transform.position, cameraRig.transform.forward * rayLength, Color.red, 0.5f);

Since you just need the transform information about your CameraRig you can get it as a game object and then drag and drop it in the script from Unity

I got it working now with my code :slight_smile: Howerver the β€œlaser” can only go from side to side? I cant make it follow when I look up and down? I need the laser to point downwards when I look down so I can pick up objects.
5129261--507008--upload_2019-11-1_11-27-14.jpg

I think I need a forward or something somewhere around here:
5129261--507011--upload_2019-11-1_11-31-12.png
But when I add a forward any of the places I think of, its gives me an error with Vector3??