Grabbing objects for humanoids
Humanoid Control supports grabbing and dropping objects in a natural way. This article describes how this works and how you can tailor this to your needs.
Humanoids are able to hold objects in their hands when more than one finger is closed. The closing of the hands can be done by tracking directly (with Leap Motion), using Finger Movements from Controller Input or by setting the Hand Pose directly.
As soon as the hand opens again, the object is dropped automatically. It is important to note that this is true even if you put an object in an hand explicitly in the scene or by using a Grab() function call on the hand target. Objects are only held when more than one finger is closed.
Humanoids can grab any Rigidbody, including Kinematic Rigidbodies. Next to that, static colliders can be grabbed if an Handle Component has been placed on the object.
If Physics has been enabled in the settings, heavy objects (mass > 1) will use the physics engine to simulate their weight. This means that while these objects are held that the hand tracking is no longer 1:1. More information on this and more on physics can be found on the Full Physics documentation page.
A Rigidbody is grabbed when one of its colliders is touched with the hand and more than one finger is closed. The location where the Rigidbody is held is the touching location unless an Handle Component is placed on the Rigidbody object.
When you want to prevent grabbing of an Rigidbody, you can place the NoGrab Component on the GameObject. Rigidbodies with the NoGrab Component cannot be grabbed.
When a static collider is held at the location of the Handle, it will not move with the hand’s movements. Instead the humanoid itself will move based on the hand movements. This enables you to climb static objects by pulling yourself up using the handles.
As it is required to touch an object in order to be able to grab it, it is normally not possible to grab objects outside the reach of the hands.
If this is desireable, the Telegrabber component can be used. This is a special kind of Interaction Pointer which will grab an object when it is clicked.
The easiest way to use the telegrabbing is to use the Telegrabber prefab found in Assets/Humanoid/Prefabs/Interaction. This prefab can be placed as a child of one of the Hand Targets. After this, you can adjust the direction of the interaction capsule or ray by manipulating the Transform of the Telegrabber.
Beware that the ray or Capsule does not cover the hands, or you will not be able to grab objects (because you will try to grab your own hands, which always fails).