- Home /
 
 
               Question by 
               NikitaChernov · Oct 12, 2017 at 04:00 PM · 
                cameravrsteam  
              
 
              How to access to SteamVR Camera?
Hello!
I'm in trouble with accessing SteamVR camera via c#. I'am using VRTK, i am trying get refence in Start() using Camera.main. But I'am getting error: NullReferenceException: Object reference not set to an instance of an object.
What do I do wrong?
Thanks
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by NikitaChernov · Dec 27, 2017 at 12:45 AM
i have found answer by myself. Simple example below, if you use VRTK version 3.2.0
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using VRTK;
 
 public class Sample: MonoBehaviour {
 
         public GameObject cameraRig;
         public GameObject playerHead;
         public GameObject playerBody;
     
         void Awake(){
             VRTK_SDKManager.instance.AddBehaviourToToggleOnLoadedSetupChange (this);
         }
     
         // Use this for initialization
         void Start () {
             cameraRig = VRTK_DeviceFinder.PlayAreaTransform ().gameObject;
             playerHead = VRTK_DeviceFinder.HeadsetTransform ().gameObject;
             playerBody = cameraRig.transform.GetChild (3).gameObject; // Only if you have VRTK Body Physics script attached!
         }
 
 }
 
              Your answer
 
             Follow this Question
Related Questions
Steam VR second untracked camera on display 2 0 Answers
Realtime Reflections in VR - Cross-eyed 0 Answers
HTC Vive Camera Height [VRTK] [Steam VR] [Open VR] 1 Answer
Steam VR Render object to only one eye 1 Answer
VR camera position instant flick 0 Answers