Introduction to Grab-related functions
Letβs find out the functions related to Grab.
Get an event when you press the Grab button for the first time and when you release it.
You can know the timing when you press the Grab 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 Grab button for the first time
function OnVRControllerLeftSqueezeStart(e) {
console.log("HELLO SQUEEZE LEFT. ", e);
}
// When you press the left Grab button and release it
function OnVRControllerLeftSqueezeEnd(e) {
console.log("BYE. SQUEEZE LEFT ", e);
}
// When you press the right Grab button for the first time
function OnVRControllerRightSqueezeStart(e) {
console.log("HELLO SQUEEZE RIGHT. ", e);
}
// When you press the right Grab button and release it
function OnVRControllerRightSqueezeEnd(e) {
console.log("BYE. SQUEEZE RIGHT ", e);
}
In the image results below, you can see that the log is taken well when you press and release the Grab buttons on both sides.