How to throw a basketball into a hoop using leap motion?

I’m trying to create a blueprint for the character to be able to pick up a ball and throw it into a hoop. At the moment I have followed getnamo’s tutorial and it works fine for picking up and dropping the ball, but how would I go about being able to successfully throw it in a realistic motion?

You’ll need to add physics to the ball and allow gravity. Throwing is a difficult motion for Leap Motion because the user typically moves their hand out of the sensors’ field of view, so focus on small movements. Is it not throwing as far as you would hope? Maybe lower the amount of mass or tinker with the physics parameters.

For throwing I generally do this:

  1. Update a velocity vector parameter for the hand your throwing with, e.g. palm location (PositionNow-PositionLastFrame)/DeltaTime
  2. At the moment you release an object, detach it from your hand like in the tutorial and turn it into a physics object
  3. Get the velocity at the moment of release and add it as an impulse (you may have to scale the velocity to feel right)
  4. If you’re being fancy add rotational velocity as an extra kick. When we throw in real life a lot of the final velocity is from the final wrist snap. This is hard to get right in VR especially for devices which guess rotation.
  5. Consider releasing early (e.g. when grabbing is <0.7 instead of 0.5) it will feel snappier