Is there an easy way to get controller velocity / angular velocity?

Hi @RaananW,

I’m wondering if there is any pre-built method like getVelocity, getAngularVelocity from the hand controllers or do I need to calculate those myself frame by frame? I’m trying to implement a realistic “throw an object” experience in VR.

Thanks

Hi owen, if you enable the physics module for the hands you can use the different impostors to get the velocity. It’s calculated by babylon itself (and doesn’t come from webxr) - https://doc.babylonjs.com/divingDeeper/webXR/WebXRSelectedFeatures#hands-physics

Thanks. The link you sent me to is using HAND_TRACKING:

featureManager.enableFeature(BABYLON.WebXRFeatureName.HAND_TRACKING, "latest", {
  xrInput: xrHelper.input,
  jointMeshes: {
    enablePhysics: true,
    physicsProps: {
      impostorType: PhysicsImpostor.BoxImpostor,
      friction: 0.5,
      restitution: 0.3,
    },
  },
});

But if I’m not using HAND_TRACKING, should I be using PHYSICS_CONTROLLERS instead? There seems to be no mention of PHYSICS_CONTROLLERS on that documentation page anymore. Does HAND_TRACKING replace it?

Also FYI, I just tried both of the Walking locomotion playgrounds on that page and both of them are broken with errors. Something about a missing mesh.

Oh, sorry, i didn’t notice you are talking about controllers and not hands. Yes, in this case you will need to enable the physics for the controllers and then use the impostors created there.

Ping @syntheticmagus regarding the demos, I’ll try checking them later as well

I’m still having a bit of trouble finding access to the imposter. I have tried:

inputSource.onMotionControllerInitObservable.add(motionController => {
  motionController.rootMesh.physicsImpostor  // appears to be undefined
})

Is there some other way to get to the physicsImposter?

You should be able to get the impostor using this function:

it’s part of the physics feature. The input source is the controller itself