Forum Discussion
NullReference
13 years agoHonored Guest
Forward vector?
How do you get the direction the player is currently looking as a vector? Like if you needed to raycast straight forward for instance. Normally I would use PlayerCamera.transform.forward but that is obviously not possible with the stereo rendering set up the rift has.
6 Replies
Replies have been turned off for this discussion
- MarbasHonored GuestYou should be able to get the forward vector from the parent object of the stereo cameras.
- AliciaSAHonored GuestI added a spotlight to my player. It didn't follow the tracking on all 3 axis until I attached it to the Right Camera, under CameraController under PlayerController. Why it didn't work at a higher level, or with the Left Camera, I don't know, but for an easy fix, make sure what you're doing is rooted at the CameraRight.
- NullReferenceHonored Guest
"Marbas" wrote:
You should be able to get the forward vector from the parent object of the stereo cameras.
That is what I thought as well, but that object doesn't rotate on the X axis. - sh0v0rProtegeGet a reference to the Right Camera game object and then:
camerRef.transform.forward; - NullReferenceHonored GuestSo the right camera is guaranteed to face directly forward from the center of the screen? Why is that?
- sh0v0rProtege
"NullReference" wrote:
So the right camera is guaranteed to face directly forward from the center of the screen? Why is that?
Right Camera is on Layer 0, all orientation tracking is applied to this camera and the others use its transform information.
In OVRCamera:SetCameraOrientation()// Main camera has a depth of 0, so it will be rendered first
if(gameObject.camera.depth == 0.0f)
The center doesn't matter because its an orientation vector, it doesn't matter where it is. If you want the centre of the eyes you will need to derive that some other way. I personally have an additional child object on the Right Camera that is offset in its local space to be in the centre. I do Raycasts from this objects Forward vector when I need to.
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 10 months ago
- 7 years ago
- 7 years ago
- 11 months ago