Choose your operating system:
Windows
macOS
Linux
Commonly in games, you will want to attach an object to the bone of a character. This might be a weapon attached to a hand, or a hat attached to the head. For this purpose, Unreal Engine allows you to create Sockets in its animation toolset - Persona - which are offset from a bone within the Skeletal Mesh. Sockets can then be translated, rotated, and scaled relative to the bone. Static Meshes and/or Skeletal Meshes can also be previewed attached to sockets. This allows content creators to easily set up sockets for a Skeletal Mesh, and then tell the programmer the names of the sockets to attach objects to.
Creating a Socket
To add a Socket to a Skeletal Mesh, you must first open that mesh in Persona. This is done by Double-clicking on a Skeletal Mesh within the Content Browser.
Sockets can be easily added onto joints within the Skeleton Tree panel by Right-clicking on the appropriate joint and choosing Add Socket from the context menu.
Sockets appear next to the name of a bone as a red socket icon, as shown in the image below.
Once a socket is named, it will immediately be created and its properties will appear in the Persona Details panel.
Socket Editing
Sockets can be edited directly within Persona by way of the Skeleton Tree, the Details panel, and the Viewport window.
By clicking on a socket within the Skeleton Tree, a translation or rotation widget becomes available in the viewport. You may use these to reposition the socket relative to the bone.
You can also edit the location of sockets numerically using the Details panel.
Viewing sockets
Along with the pink socket icon in the Skeleton Tree hierarchy, you can also view sockets directly on a mesh within the Viewport by using the Show menu and choosing Sockets.
Using sockets
Actors can be attached to Skeletal Mesh Sockets in a few ways, depending on your needs.
Desired type of attachment |
Method |
---|---|
Per-instance attachment on Skeletal Mesh placed within a level. |
Can be done in the main editor within the Viewport, using the Content Browser. See Socket Snapping and Context Menu Attachment below. |
Snapping Based on Gameplay |
This should typically be done by way of a Blueprint. See Blueprint Attachment below. |
Socket Snapping
You can attach Actors to Skeletal Mesh Sockets within the editor via Socket Snapping. This is useful when you need to make an attachment to a particular Skeletal Mesh that is already placed in the level.
First, enable socket snapping from the Settings Menu of the Level Editor Toolbar.
The viewport will then render all sockets visible. Select the Actor you wish to attach. Click on the socket that you wish to attach to.
The Actor is now at the location and rotation of the socket and is attached to the Actor who owns the skeletal mesh component of the target socket.
Context Menu Attachment
You can also attach Actors to Skeletal Mesh Sockets by way of the context menu within the main editor viewport. This does not require Socket Snapping to be activated, and as long as you know the name of the Socket you want to attach to, this can be a very fast way to make the attachment. As with the Socket Snapping technique, this is best suited to making attachments on Skeletal Meshes that have already been placed in the level.
Right-click on the mesh you want to attach. Choose Attach To > [Name of your target Skeletal Mesh]:
From the flyout menu that appears, choose the name of the desired Socket.
The Actor snaps to the location of the Socket.
This method only works for attaching to a Skeletal Mesh asset and will not work for attaching to a socket located on a Blueprinted asset.
Blueprint Attachment
There will almost certainly come times when you want a Skeletal Mesh to receive an attachment that is determined by gameplay in some way. For instance, maybe a character needs to pick up a weapon when they run across it. This can easily be done in Blueprints. Since there are myriad ways in which this could be applied, we will simplify our discussion here to simply pointing out useful nodes, from which point you may create whatever type of logic needed to make the attachment happen when and how you desire. For more information on Blueprint, please see the Blueprint documentation pages.
Attach Actor to Actor
Attach Actor to Component
Attach To