I am working on a project with Unity and Leap Motion. Basically, there is an inputField. In the inputField the user will write the distance, in centimeters, for which the grasp event should be triggered. When the fingers get closer than the distance of the user's input, the grasp event is triggered and a ball is grabbed. That's because I'm working with people with movement deficits and they can't fully close their hands.
I've written a script that prints the distance between the two fingers at each frame, but I don't know how to trigger the grasp event using the distance of the inputField. Any advice?
The most straightforward way to implement this is to introduce a variable which reads the content of the inputField and an if statement that triggers the event on Update() within the script you have written - something like that (assuming you're calculating graspDist as you described):
and then you define your TriggerGraspEventFunction() somewhere else within that script. You can either make the gameObjectWithInputField a public GameObject and drag it in in the inspector or tag it and use FindGameObjectWithTag
There are many more refined ways but this should do it for now