Socket Interaction to Get Things Done

Create a Socket Interactor that Opens the Door if a Key is Placed within the Socket

Jordan T Kay
3 min readMay 4, 2024

To have to door open by placing a key into the socket, we need to do the following…

  1. Configure A Key Hole
  2. Adjust the socket position
  3. Execute Door Animation
  4. Have door open for only a key

STEP 1 — CONFIGURE A KEY HOLE

To configure a key hole, we need to…

  • Import a key hole object
  • Attach a sphere collider and set it to trigger
  • Attach XR Socket Interactor Component

WHAT IS A XR SOCKET INTERACTOR?
The XR SOCKET INTERACTOR is an interactor used for holding interactables via a socket.
Just as a Direct Interactor is used to enable controllers to interact with interactables, the Socket Interactor allows other objects within the virtual world to interact with interactables.

STEP 2 — ADJUST THE SOCKET POSITION

Just as we did to our pistol, we need to customize the attachment point of our socket interactor.

← ← ← ← ← ← ← ← ← ← ← ← ← ← BEFORE | AFTER → → → → → → → → → → → → →

STEP 3 — EXECUTE OPEN DOOR ANIMATION

When we place the key within the key hole, we want the door to open. To do this, we need to call a trigger parameter within the animator held on the door using the Interactor Events on the XR Socket Interactor.

STEP 4 — ONLY KEYS SHOULD WORK

As of right now, the lock works… alittle to well. Any interactable object can be placed on the socket and open the door. What we want, is only objects that are defined as a key should be able to be placed on the socket and unlock the door.

To accomplish this, we need to create a new Interaction Layer Mask and name it Keys. Then define the XR Grab Interactable on the Key to the newly created Keys interaction layer mask.

TEST

--

--

Jordan T Kay

Join my journey into game development with Unity. Learning all I can to produce quality games. 🚀