SnippetVRIntroduction of Controller-Related FunctionsIntroduction to Trigger-related functions

Introduction to Trigger-related functions

Let’s find out the functions related to Trigger.


Get an event when you press the Trigger button for the first time and when you release it.

You can know the timing when you press the Trigger button for the first time and when you release it through the code below.

// VR Default Setting
const avatar = REDBRICK.AvatarManager.createDefaultAvatar();
const camera = WORLD.getObject("MainCamera");
const followingCamera = avatar.setFollowingCamera(camera);
avatar.setDefaultController();
followingCamera.useVR({ VRObject: avatar });
 
// When you press the left Trigger button for the first time
function OnVRControllerLeftSelectStart(e) {
  console.log("HELLO LEFT. ", e);
}
 
// When you press the left Trigger button and release it
function OnVRControllerLeftSelectEnd(e) {
  console.log("BYE.LEFT  ", e);
}
 
// When you press the right Trigger button for the first time
function OnVRControllerRightSelectStart(e) {
  console.log("HELLOW RIGHT. ", e);
}
 
// When you press the right Trigger button and release it
function OnVRControllerRightSelectEnd(e) {
  console.log("BYE.RIGHT ", e);
}

In the image results below, you can see that the log is taken well when you press and release the Trigger buttons on both sides.


trigger_img1