We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

VR Controller Vibration

Home Forums General Questions VR Controller Vibration

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #80625
    tomtm
    Customer

    Hi,
    here is a javascript code how to vibrate your controllers, at least with a Meta Quest 3.

    // for left contrroller
    const xrSession = app.renderer.xr.getSession();
    if (xrSession) {
    for (const inputSource of xrSession.inputSources) {
    if (inputSource.handedness === “left”) { // only left controller
    const gamepad = inputSource.gamepad;
    if (gamepad && gamepad.hapticActuators && gamepad.hapticActuators.length > 0) {
    gamepad.hapticActuators[0].pulse(1.0, 100); // intensity 1.0 time 100ms
    }
    }
    }
    }

    // for right controller
    const xrSession = app.renderer.xr.getSession();
    if (xrSession) {
    for (const inputSource of xrSession.inputSources) {
    if (inputSource.handedness === “right”) { // only right controller
    const gamepad = inputSource.gamepad;
    if (gamepad && gamepad.hapticActuators && gamepad.hapticActuators.length > 0) {
    gamepad.hapticActuators[0].pulse(1.0, 100); // intensity 1.0 time 100ms
    }
    }
    }
    }

    Now my question:
    With the onhover puzzle, it will always detect the right or left controller.
    How can I find out which controller hovers an object and then trigger the vibrate function
    above?

    Thanks Tom

    #80626
    kdv
    Participant

    raycasting.

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.