Skip to main content
‹ Back to Tutorials
Intermediate Unity

Unity VR XR Interaction Toolkit - XR Socket Interactor

Aug 23, 2022
About this tutorial

In this Unity VR XR Toolkit tutorial, I'll show adding an electric box with the XR Grab Interact component and then being able to attach it to a base set up with a XR Socket Interactor component. ► Art Assets - Polygon City - Low Poly https://bit.ly/3ScOYa1 My discord link ► https://discord.gg/DgU

Written Guide

Picking objects up in VR is one thing; snapping them into a specific place is another. This tutorial pairs XR Grab Interactable with XR Socket Interactor to build a light box the player can grab off the floor and click into position on a light pole — the standard pattern for assembly, repair, and puzzle mechanics in VR.

Step 1 — Make the light box grabbable Select the box and add an XR Grab Interactable component. Unity adds a Rigidbody automatically. On that Rigidbody, change Collision Detection from Discrete to Continuous Dynamic — grabbed objects move fast in VR and discrete detection will let them tunnel straight through walls and floors.

Step 2 — Smooth the grab In the XR Grab Interactable component, enable Smooth Position and Smooth Rotation. Without these the object snaps rigidly to hand movement, which is technically accurate and visually jittery. Smoothing keeps the object tracking your hand while filtering out the small tremors that make VR objects look unstable.

Step 3 — Add an attach point to the box By default a grabbed object attaches at its own origin, which is rarely where you want it. Create an empty game object as a child of the box and name it Attach Point. Move it to the far left side of the box, centered vertically, then assign it to the Attach Transform field on the XR Grab Interactable. This single transform does double duty: it defines where the box sits in the player's hand and where it aligns when socketed.

Step 4 — Orient the box for a natural drop Rotate the box slightly before play so that when it falls under gravity it settles flat on the ground rather than landing on a corner and rolling. A small detail, but a box resting awkwardly on an edge is the kind of thing that reads as broken to a player.

Step 5 — Turn the pole base into a socket Select the base on the light pole and add an XR Socket Interactor component. Then change its Box Collider from a solid collider to a trigger by checking Is Trigger — the socket detects objects entering its volume, and a solid collider would block the hand instead. Enlarge the trigger volume beyond the visible geometry so the player has room to bring their hand into the space without fighting the boundary. Sockets that require pixel-perfect placement feel terrible in VR; a generous trigger is what makes the snap feel forgiving.

Step 6 — Add the socket's attach point The socket needs its own attach transform defining where the held object lands. Create another empty game object, name it Attach Point, and position it on the right side of the pole base. The logic here is worth spelling out: the box's attach point is on its left, the socket's is on its right, so when the two transforms align the box seats flush against the base rather than intersecting it. Assign this transform to the Attach Transform field on the XR Socket Interactor.

Step 7 — Test the interaction Enter play mode and approach the box on the floor. Grab it and it comes into your hand at the attach point, rotating with your wrist. Move it toward the pole base and the socket previews a ghost of where the box will land. Release and the box snaps cleanly into place on the pole.

The connection works, but the light still doesn't turn on — that's handled in the next tutorial. What you have here is the reusable half: any grabbable object plus any socket, aligned by matched attach transforms.

Unity tools by Bliz Studio
Built for our own games — now on the Asset Store

Multi Tag — unlimited hierarchical tags for any GameObject. Hierarchy Pro — style your whole hierarchy with rules. Made by a Unity dev, for Unity devs.

Explore our Unity assets →