With this week’s Unity Core Asset release , we’ve made a few changes to ourPinch Utilities – including some new features that extend its capabilities! These new utilities have been folded into the main Core Assets package, retiring the former Pinch Utility module.
So what are these new features? We call them Detectors, and they provide a convenient way to detect what a user’s hand is doing. In addition to detecting pinches, you can now detect when the fingers of a hand are curled or extended, whether a finger or palm is pointing in a particular direction, and whether the hand or fingertip are close to one of a set of target objects. (A grab detector is coming soon!)
What’s more, these detectors can be combined together using a Logic Gate. The Detector Logic Gate is itself a detector that logically combines two or more other detectors to determine its own state. Need a thumbs up gesture? Combine a thumb-extended detector with a thumb-pointing-upward detector using a logic gate.
This gate is configured as an AND gate. You can also use NOT, NAND, and NOR gates.
The thumb pointing up detector is active, but the other fingers are also extended – so no thumbs up is detected.
Detectors dispatch standard Unity events when they activate or deactivate. This makes it easy to hook up objects and scripts to a detector straight from the Unity editor — without writing a line of code.
Each detector can draw gizmos that make it easy to see its configured conditions and whether it’s currently active or inactive.
Detectors are designed to be small building blocks that you can put together into something interesting. This also has the benefit that it is easy to write your own detector scripts.
You can find all the Detector scripts, including the PinchDetector, as part of the Unity Core Assets. Example scenes are located in the Detection Examples package , which also contains an additional scene that illustrates how to use detectors.