Snapping
Snapping is a commonly used tool for creating interactions, allowing one object to ‘snap’ to another and hold it in place with a ParentConstraint. This functionality is achieved using the Snapper and SnapTarget components.
Snappers also integrate with Handles to enable snapping whenever the handle is released. To set this up, simply reference the snapper in the handle’s snapper field in the inspector.
Snapping can also be performed programmatically by using the Snap
or SnapTo
methods.
using ImmerseSDK.Interaction.Snapping;
// Snap to the nearest valid target
snapper.Snap();
// Snap to a specific target (requirements will be ignored)
snapper.SnapTo(snapTarget);