Grabbable
Updated: Aug 7, 2024
A
Grabbable
component is what makes a GameObject rotate, scale, or transform when you interact with it. It also handles velocity calculations if you throw an object.
To decide how the GameObject should rotate, scale, or transform, Grabbable
uses transformer components. Transformer components are split into two main categories.
- One-hand grab transformers, which require only one hand.
- Two-hand grab transformers, which require both hands.
The types of hand grab transformers. Transformers whose names start with “One...” require only one hand. Transformers whose names start with “Two...” require both hands.
Note: If you want to call OnEnable()
, you must set the Forward Element property first.
You should assign
One Grab Transformer components to the
One Grab Transformer property in the
Grabbable
component. Once you’ve done that, set your interactable’s
Pointable Element field to the
Grabbable
component.
This transformer is useful when the
Grabbable
is a physical entity that needs to keep colliding (non-kinematic) with the environment during a transformation or when it is attached via Physics Joints to the environment, as is common in the cases of a
Grabbable
physics door or lever.
The optional Custom Joint allows setting the irrelevant motions to Free plus other features such as pre-processing. It can help with the creation of custom behaviors and remove the occasional physics glitches. This optional Custom Joint should be placed on a disabled GameObject as it will get copied during runtime.
You should assign
Two Grab Transformer components to the
Two Grab Transformer property in the
Grabbable
component. Once you’ve done that, set your interactable’s
Pointable Element field to the
Grabbable
component.
Note: If you add a Two Grab Transformer component, then you need to also set the One Grab Transformer property since it will no longer auto-generate.
TwoGrabRotateTransformer
updates the rotation of a
Grabbable
, taking into account rotation changes of two pointable targets about a pivot (with optional constraints for min/max rotation).
TwoGrabPlaneTransformer
updates the position and scale of a
Grabbable
about a given plane, as well as its rotation about a given axis (with optional constraints for position and scale).