cancel
Showing results for 
Search instead for 
Did you mean: 

Having trouble getting the Go controller to work with my camera setup : Unity

Superframe
Protege
Hello 🙂

I have a "Player" which travels around a track, and a camera that is parented to that. My shooting mechanism traces a ray from the camera center in the direction the camera is looking. It works great if you want to use the camera direction to aim. However, I am trying to get the Oculus Go hand controller to also help aim.

The "Player" never rotates, but the camera (parented to the "Player") does.





I am using this code:

Quaternion _rotation = OVRInput.GetLocalControllerRotation (OVRInput.Controller.RTouch);
Vector3 targetForward = _rotation * Vector3.forward; //convert from quaterion  
Vector3 fwd = camTarget.transform.TransformDirection (Vector3.forward+targetForward) ;  
Physics.Raycast (camTarget.transform.position, fwd, out hit); 

this works when the game starts, with the aiming direction being a combination of the look direction and the hand controller direction but the firing direction gets off as the player turns around.

I have also tried not adding the camera direction to the hand controller direction:
Vector3 fwd = camTarget.transform.TransformDirection (targetForward);  

Aim gets off again.

This is the code that works, but again only using the camera direction and ignoring the hand controller.

Vector3 fwd = camTarget.transform.TransformDirection (Vector3.forward) ;  
Physics.Raycast (camTarget.transform.position, fwd, out hit); 

Any help or thoughts on how to accomplish this are appreciated.
Greg Bowen - Founder
1 REPLY 1

Superframe
Protege
I got this working. I just started over with the OVRCamera rig - got the controller working, and started bringing things back one at a time..
Greg Bowen - Founder