---
title: "1.4 - Sockets"
content_type: tutorial
url: "https://learn.unity.com/tutorial/1-4-sockets?language=en"
language: en
difficulty: beginner
duration_minutes: 90
unity_version:
  - "6.3"
  - "6.2"
  - "6.1"
  - "6.0"
supported_unity_versions:
  - name: "6.3"
    url: "https://learn.unity.com/tutorial/1-4-sockets.md?language=en&version=6.3"
  - name: "6.2"
    url: "https://learn.unity.com/tutorial/1-4-sockets.md?language=en&version=6.2"
  - name: "6.1"
    url: "https://learn.unity.com/tutorial/1-4-sockets.md?language=en&version=6.1"
  - name: "6.0"
    url: "https://learn.unity.com/tutorial/1-4-sockets.md?language=en&version=6.0"
  - name: "2022.3"
    url: "https://learn.unity.com/tutorial/1-4-sockets.md?language=en&version=2022.3"
  - name: "2021.3"
    url: "https://learn.unity.com/tutorial/1-4-sockets.md?language=en&version=2021.3"
last_updated: "2026-08-04T14:21:59.000Z"
---

# 1.4 - Sockets

Learn to configure VR sockets so objects snap into place, letting users hang hats on hooks and wear them in Create with VR.

In this lesson, you will learn how to configure sockets that objects can snap into in VR. By the end of this lesson, users will be able to hang hats up on hooks - and even wear the hats too!

This lesson is part of the [Create with VR course](https://learn.unity.com/course/create-with-vr).

## Add grabbable hats to the scene

Sometimes you want the user to be able to attach or place GameObjects in predefined positions—this is where sockets are useful. Sockets are predefined attachment points that let users grab GameObjects, place them, or snap them into specific positions within the virtual environment.

In this lesson, you’ll create hooks for hats.

Before making a functional hook for hats, you’ll first need some grabbable hats.

[Video](https://connect-mediagw.unity.com/h1/20250912/videos/fc97c721-f884-4f5f-9172-f9ff3f6985e7_1.4.1.mp4)

**1.   Add some hats to your scene:**

- Open the **\_Course Library** > **\_Prefabs** > **Objects** > **Hats** folders.
- Drag two hats you might want to wear onto a surface near the mirror.

**Note:** If you don’t already have a set of hooks in your scene, add one from the **\_Course Library** > \_**Prefabs** > **Hooks** folder.

**2.  Make the hats obey physics:**

- Use **Ctrl** (macOS: **Cmd**) to select both hats in the **Hierarchy** window.
- Add **Rigidbody** components to the selected **Hat** GameObjects.
- Set the **Collision** **Detection** property to **Continuous Dynamic** to prevent the **Hat** GameObjects from falling through the ground.

**3.  Make the hats grabbable:**

- Add **XR** **Grab** **Interactable** components to each **Hat** GameObject.
- If you want, enable the **Smooth Position** and **Smooth Rotation** properties to reduce jitter.

**4.  Prepare for testing:**

- Reposition and reorient the **XR Origin** **(VR)** GameObject to be in front of the **Mirror** GameObject and within reaching distance of the **Hook** and the **Hat** GameObjects.

You should now be able to successfully pick up the hats.

## Turn the hook into a socket

To be able to hang the **Hat** GameObjects on a hook, the hook will need to behave like a socket.

[Video](https://connect-mediagw.unity.com/h1/20250912/videos/2c8e6769-312b-487a-a830-573f8b638ad5_1.4.2.mp4)

**1.  Position the socket correctly:**

- In the **Hierarchy** window, right-click the **Hook** GameObject and create an empty child GameObject.
- Rename the child GameObject “Socket 1”.
- Reposition the **Socket 1** GameObject to the tip of the hook, where the **Hat** GameObject will rest.

**2.  Define the trigger detection area for the socket:**

GameObjects that enter the trigger area will snap to the socket.

- Add a **Sphere** **Collider** component to the **Socket** GameObject.
- Select the **Edit Collider** button and reduce the **Radius** property to something around **0.1**.
- Enable the **Is Trigger** property to prevent it from colliding with the **Hat** GameObject.

**3.  Make the Socket 1 GameObject behave like a socket:**

- Add an **XR** **Socket** **Interactor** component to the **Socket 1** GameObject.

**4.  Make the Hat GameObject point downward when attached to the socket:**

- Create an empty child GameObject of the **Socket** **1** GameObject and rename it “Attach”.
- Rotate the **Attach** GameObject to face downward.
- Assign the **Attach** GameObject to the **Attach Transform** property of the **XR** **Socket** **Interactor** component.

**Note:** The local Z axis of the attach point should align with the desired forward direction of the hat and the local Y axis should align with its desired upward direction.

You should now be able to pick up and place any of your hats onto the socket you set up.

## Duplicate the sockets and attach hats

Now that you have one fully functional socket, you can duplicate it for the other hanging locations on the hook and have the hats start on hooks when the scene loads.

[Video](https://connect-mediagw.unity.com/h1/20250912/videos/5f1f7487-7709-4e65-a23f-c5064ac5cb54_1.4.3.mp4)

**1.  Create sockets for all the hanging locations:**

- In the **Hierarchy** window, duplicate the **Socket 1** GameObject twice.
- Rename the copied GameObjects “Socket 2” and “Socket 3”.
- Reposition the copied sockets for the other two hanging hook locations.

**2.  Have your hats start on the hooks by default:**

- In each of the **Socket** GameObject’s **XR Socket Interactor** components, assign one of your hats to the **Starting Selected Interactable** property.

**Note:** If you only have two hats, one of the sockets should have “None” for its starting interactable property.

All three of your sockets should now be fully functional, with hats starting on the hooks at the start of the scene.

![](https://connect-mediagw.unity.com/h1/20250912/learn/images/e2c7c838-dda0-497a-b300-367d7bacf3d8_HatsOnSockets.png)

## Put hats on your head

These hats and this mirror would really be wasted unless you could actually wear the hats on your head.

[Video](https://connect-mediagw.unity.com/h1/20250912/videos/5a941498-57b3-4ad4-8166-38f9c96cade1_1.4.4.mp4)

**1.  Position the head socket GameObject correctly:**

- In the **Hierarchy** window,  right-click the **XR Origin** > **Camera Offset** > **Main Camera** GameObject and create an empty child GameObject.
- Rename this new child GameObject “Socket”.
- Set the **Socket** GameObject’s **Transform** component’s **Position** property’s **Y** value to **0.1** so that the **Hat** GameObject appears above your eyes.

**2.  Add a trigger detection area for the Socket GameObject:**

- Add a **Sphere** **Collider** component to the **Socket** GameObject.
- Select the **Edit Collider** button and set the **Radius** property to something around **0.2**.
- Enable the **Is Trigger** property.

**3.  Allow the hats to snap to this socket:**

- Add an **XR** **Socket** **Interactor** component to the **Socket** GameObject**.**

You should now be able to put the hats on your head and see how they look in the mirror.

## Prevent other GameObjects from acting like hats

You can currently put all GameObjects on your head or on the hooks as if they were hats. You can use **interaction layers** to control which GameObjects can and cannot interact with each other.

[Video](https://connect-mediagw.unity.com/h1/20250912/videos/5a589ed6-2b2b-45a5-b7fa-5247419c5c38_1.4.5.mp4)

**1.  Add a new Hats layer:**

- Select a **Hat** GameObject.
- In the upper-right corner of the **Inspector** window, open the **Layer** dropdown and select **Add Layer**.
- Add a new “Hats” layer in the first available empty slot.

**2.  Put the hats on your new Hats layer:**

- In the **Hierarchy** window, select all of your **Hat** GameObjects using **Ctrl**+**Click** (macOS: **Cmd**+**Click**).
- In the **XR** **Grab** **Interactable** component, open the **Interaction Layer Mask** dropdown, select **Nothing** to clear the layers, then select the **Hats** layer to enable only that layer.

**3.  Make sure the hook and head sockets can only interact with GameObjects on the Hats layer:**

- Set each of the **Hook** and **Head** **Socket** GameObjects’ **Interaction Layer Masks** property to the **Hats** layer.

**4.  Make sure other GameObjects cannot be used as hats:**

- Select all of your other grabbable GameObjects.
- Open the **Interaction Layer Mask** dropdown and enable only the **Default** layer.

You should now only be able to put hats - and not any other grabbable GameObjects - on your head and the hooks.

## Recap

[Video](https://connect-mediagw.unity.com/h1/20210319/videos/951d6d5b-7a4b-4ffe-94c0-6ab464283334_1_4_recap_v1.mp4) ([Transcript (en)](https://connect-mediagw.unity.com/h1/20210402/7c18c49b-72d4-43ac-8403-bcf1c604e44c_1_4_recap_v1.vtt))

**New Features:**

- Added hats
- Hang hats on hooks
- Put hats on your head

**New Concepts & Skills**

- Socket interactors
- Triggers to detect interaction
- Interaction layer masks

**Next Lesson:**

- Audio and Haptics

## Extensions _(Optional)_

If you want to further develop your skills, explore new concepts, and improve your project, check out some of the optional extension activities below.

Each one is tagged as \[Easy\], \[Medium\], \[Difficult\], or \[Expert\] and will also include a \[Requires Programming\] tag if some coding is required.

**1.  Add rearrangeable art \[Medium\]:**

Allow the user to swap the position of art hanging on the wall:

- To make a simple hook, create an empty GameObject with a **Socket** **Interactor** component, then create a primitive cube child GameObject, scaled and rotated appropriately, to represent the mesh.

To make the pieces of art hang at the correct height, you might need to add an **Attach** **Transform** located at the position on the frame the art would hang from.

[Video](https://connect-mediagw.unity.com/h1/20210211/videos/02477ef6-4649-4b93-a22d-3406c20082ac_1.4.ext_art_swap.mp4)

**2.  Add books to a bookshelf that can be rearranged neatly in any order the user wants:**

- In order to get the books to appear at the orientation you want, try creating an empty GameObject with the correct orientation, then making the **Book** GameObject a child GameObject.

[Video](https://connect-mediagw.unity.com/h1/20210211/videos/02f8c4a7-3abc-49bc-89de-dad59a49360d_1.4.ext_bookshelf.mp4)

Check out lesson related videos here.
