Component:Snapper
More actions

The Snapper component allows a slot to parent to Snap Target slots. These are popular for accessories such as hats/glasses or where items need to 'snap' into or onto a spot and stay there. For example a replaceable rose in a vase or cup to a saucer.
Usage
| Name | Type | Description |
|---|---|---|
persistent
|
Bool | Determines whether or not this item will be saved to the server. |
UpdateOrder
|
Int | Controls the order in which this component is updated. |
Enabled
|
Bool | Controls whether or not this component is enabled. Some components stop their functionality when this field is disabled, but some don't. |
UseBoundingBoxCenter
|
Bool | Causes the Snapper to use the center of its Bounding Box rather than its Origin Point. |
SnapCheckRadius
|
Float | This article or section is a stub. You can help the Resonite wiki by expanding it.
|
CheckStaticColliders
|
Bool | Allows the Snapper to look for colliders on the Snap Target's slot that are set to Static in addition to colliders set to Trigger.
|
SnapTargetWhitelist
|
list of SnapTarget | List of Snap Targets that the slot can attach to |
Keywords
|
direct SyncFieldList`1<String> | List of keywords to match against a corresponding Snap Targets. Can have multiple keywords to snap to multiple Snap Targets |
Behavior
Allows the slot in which this component resides in to snap to a Snap Target in another slot.
Upon dropping a Grabbable, if its slot's Origin Point (or the center of its slot's Bounding Box if UseBoundingBoxCenter is enabled) is within a SnapTarget's SphereCollider, the Origin Point of the dropped slot will snap to the Origin Point of the SnapTarget's slot.
If either the SnapTarget's SphereCollider, or any colliders on the Snapper or any of its children are set to Active, the Snapper's slot will be immediately snapped to the SnapTarget upon collision with the Active collider, without needing to drop the Grabbable. This is the only way to make a Snapper use a collider instead of the Origin Point or Bounding Box Center. (Note: This will also cause the Snapper's Enabled field to be ignored, you will need to enable/disable the Active collider instead.)
The SnapTargetWhitelist (list) and Keyword (list) each allows you to specify a list of Snap Target that this component will link to so you can to limit its snapability. Keywords allows you to provide a list of words(strings) while SnapTargetWhitelist uses the actual SnapTarget components.
It is important to have this in a slot shared with a Grabbable component in the root link of the object you wish to snap. Snapped components will become children of the snap target.
Detecting when Snapped
Unlike grabbers, Snappers do not have a way to detect events directly. (GH#2059)
One common way to use ProtoFlux:GetParentSlot from the Snapper slot, ProtoFlux:GetSlotName then ProtoFlux:Equals to check if matches the intended snapper.
Another is to use Dynamic variables as when snapped the item is within the parent's DynamicVariableSpace.
Examples
Video
Covering the concept:
Covering Hats! (That can cover you)