Vr click function

Hello everyone,

I am totally new here so i hope you can help me out. I am learning to use playcanvas with a little bit of javascript knowledge.

What I’m trying to do is making a vr environment where i can use my controller to click on hotspot’s.


My project is so far as good as finished, the hotspots are working and i can use VR but here it is:

My problem is that i can not use my controller to click on the hotspots?

I’m learning from the playcanvas site WebVR input

Can someone explaine why i can not click on my hotspot’s. I thought that it was because in my hotspot.js there is a line about pc.MOUSEBUTTON_LEFT event but I thought it would not matter because the controller is also a mouse event? But if it has to be different how can i call the ride line for the controller?

I’ve tried something with this but I cannot figure this out:
this.entity.on(‘controller:button:click’, this._onButtonClick, this);

Greetings

You are combining two sets of scripts that weren’t designed to work together without modification.

The VR input code is designed handle all the different input types from the various VR controllers (Cardboard/Screen touch, gamepad, VR controllers etc) whereas the hotspot code is listening for a different set of events from it’s own input controllers (mouse and touch).

If this is predominately for VR, would modify the hotspot code to listen for the events from the VR input controller scripts.

Hello yaustar,

I’ve tried this line down below and put it in hotspot.js

this.entity.on(‘controller:button:click’, this.onButtonClick, this);


Than I changed the function for the mouse input to this:

Hotspot.prototype.onButtonClick = function (sourceEntity) {
this.doRayCast(event);_
};

But it is not working. De pointer in VR is working do but unfortunately not the click function.

Greetings

@yaustar I’m running into the same problem, can you please explain how the input logic work for VR? I can’t seem to understand only looking at the example