Vr_camera.js not working on entities


I created a new VR project. The application works fine when I attach vr_camera.js to the main camera. However when the code is attached to any entity(a cube in my case), I see a black screen. Would be great to know the solution for this.


It’s not meant to be attached to non camera entities.
Use Dev Tools to debug your situation: http://developer.playcanvas.com/en/user-manual/scripting/debugging/

Hi max,

Step Two: Add the VR Camera script

The WebVR library also includes a file called vr_camera.js. This should be attached to an Entity that will behave as your camera. This Entity could already have a camera component attached (though that is not required). The VrCamera script will create a pair of cameras (one for each eye!) when VR mode is activated and disable the existing camera component.

given in

Any update on the issue

Summoning @dave to topic.

Do you have a link to the project displaying the problem?


I am also facing same issue.

Two things:

  1. There is a bug in vr_camera.js which aborts presenting if there is not a camera on the script entity. I’ve fixed this in the starter kit. You can fix this in your project. On line 158 of vr_camera.js

The line:

        self.entity.camera.enabled = false;    

Should be:

        if (self.entity.camera) {
            self.entity.camera.enabled = false;    
  1. If you don’t have an enabled camera in the scene then you will see a black screen until you enable the vr camera script (which enables new cameras). Usually you would need a non-VR camera to use until VR is activated.
1 Like

Thanks Dave. It worked.

But once I open the link on my phone, I get the following error,

Failed to recalculate device parameters. Line No. 4857 of input_hmd.js

Would be great if you could help me with this too.

Do you get any other messages above that about the device being used?

No Dave. Only that single line