Immerse SDK
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Snapper

A Snapper component is what ‘snaps’ to a Snap Target. This is typically done by grabbing an object by it’s Handle and releasing it near the Snap Target, however it is also possible to snap via code too.

Snapper component as it appears in the Inspector

Field Description
Handles Handles attached to this object. When one of these handles is disengaged, the Snapper will attempt to snap to the available target.
Start Position (Optional) The snap target this should start on.
Fallback Snap Targets These snap targets will always be considered when snapping.
On Snap Event triggered when the Snapper snaps to a SnapTarget
On Unsnap Event triggered when the Snapper unsnaps from a SnapTarget

Snapping via Code

As stated above, it is possible to snap a Snapper to a Snap Target via code.

snapper.Snap(snapTarget);

// Snap ignoring requirements (force snap)
snapper.Snap(snapTarget, true);

This method can also be called from the Snap Target, with the Snapper as the parameter.

snapTarget.Snap(snapper);

// Snap ignoring requirements (force snap)
snapTarget.Snap(snapper, true);