Home › How do I…? › How to snap objects into place in VR

How to snap objects into place in VR

Advanced Framework Pro snaps with a pair of components: a connector on the movable object and an anchor on the target. When the player holds the object near the anchor, a ghost shows where it will land, and releasing places it exactly, oriented correctly no matter how it was grabbed. By the end of this you will have a part that fits only its own slot, and optionally one that sits flat on any wall or table.

At a glance

Movable object (grabbable)
└─ BPC_Connector_Anchor      Connector ID = Battery, Release Type, Search Distance,
                             Show Snapping Preview, Show Anchors On Search
   or BPC_Connector_Surface  Rotate On Surface, Wall Rotation Adjustment
Target
└─ BPC_Anchor                Connector IDs To Allow = [Battery]  (empty = any)
Events on the anchor: attach, detach

Steps

  1. Custom Depth-Stencil must be on for the preview; the Setup window's Required page turns it on (Custom depth with stencil).
  2. Make the object grabbable first; see How to make an object grabbable.
  3. On the object, add BPC_Connector_Anchor and move it to the point that should meet the target. Set Connector ID, for example Battery.
  4. On the target, add BPC_Anchor, place it where the object should sit, and add the same ID to Connector IDs To Allow. Leave the list empty to accept any connector.
  5. Set Release Type on the connector: attach, snap in place, or physics drop.
  6. Turn on Show Snapping Preview for the ghost and, if useful, Show Anchors On Search to reveal compatible slots while the object is held.
  7. For placing on surfaces instead of slots, use BPC_Connector_Surface and choose Rotate On Surface: keep rotation, align to the surface, or align and face the player.
The battery held beside its slot, snap preview showing where it will land
AFS_Core_Snapping_result.pngThe battery held beside its slot, snap preview showing where it will land
The battery held beside its slot, snap preview showing where it will land

Notes

Bind to the anchor's attach and detach events to react: a machine that starts when all parts are in, a lamp that lights when the bulb is seated.

Keyed IDs give you assemblies: each part fits only its own anchor, and one anchor can list several IDs.

Search Distance sets how close the object must come before a slot is offered. Keep it small for dense assemblies.

Multiplayer

Attachment replicates; every client sees the same connection.

Nothing snaps? The connector ID is missing from the anchor's allow list, or Search Distance is too short.

Map_Examples_Snapping has five stations: battery and bulb slots, the three release types on a tray, surface placement with Requires Tag, a rifle assembled from keyed parts, and a gear machine driven by anchor events.