ssc
In that case, rather than copying an existing attachment, you need to create a new one.
There are two kinds of attachments that can be rendered: RegionAttachment and MeshAttachment.
Unless you know the shape of the mesh, you probably want to create a RegionAttachment, which is just a rectangle.
To do that, you just need to call the constructor and set some properties:
const slot = player.skeleton.slots.find(slot => slot.data.name == "gun");
const newAttachment = new spine.RegionAttachment(region.name, region.name);
newAttachment.region = region;
newAttachment.width = region.width;
newAttachment.height = region.height;
slot.setAttachment(newAttachment);
slot.attachment.updateRegion();
You can change the coordinates, angle, and size of the attachment by modifying the following properties: x
, y
, rotation
, width
, height
.