MagneticPinchΒΆ

Attach this script to a RigidHand object to enable grabbing moveable Unity objects by pinching. The script uses a simple distance check and pulls the object to the hand (rather than simulating the physics of picking up an object by contact). You can specify the range and the strength of the force that moves the object to the hand.

unity/../../../images/unity/Unity_MagneticPinch.jpg
class MagneticPinch

Detects pinches and grabs the closest rigidbody if it’s within a given range.

Attach this script to the physics hand object assinged to the HandController in a scene.

Public Members

float forceSpringConstant

The stiffness of the spring force used to move the object toward the hand.

float magnetDistance

The maximum range at which an object can be picked up.