Accessory Attachments behavior changed/inconsistent

Reproduction Steps
Certain accessory attachments are behaving differently. I haven’t changed any of the code that handles this for years.
https://gyazo.com/b67efaae2f8ec4445c54d5ef8b881045
image

you can see the torso and right upper leg accessories are attached to the neck and waist.

accessory attachment bug repro.rbxl (30.3 KB)
In this test place you can see two accessories that are attached to LeftHipRigAttachment and RightHipRigAttachment act differently. One moves with the leg and one moves with the lower torso.
Also a third accessory attached to NeckRigAttachment which USED to move with the torso but now moves with the head.

Expected Behavior
I haven’t changed the code in my game for a while so I would expect the accessories to move with the body parts they are attached to.

Actual Behavior
It chooses the hip instead of the right leg, and it will choose the head instead of the upper torso.

Issue Area: Engine
Issue Type: Other
Impact: Moderate
Frequency: Constantly
Date First Experienced: 2021-08-01 00:08:00 (-04:00)
Date Last Experienced: 2021-10-05 00:10:00 (-04:00)

5 Likes

Thanks, we are looking into it!

2 Likes

The issue here is that your Accessories are using RightHipRigAttachment , LeftHipRigAttachment , and NeckRigAttachment which are all rig attachments. You can’t use any Attachments that have rig in the name. Can you update your Accessorys to use any of the Attachments in the character that do not have rig in the name?

3 Likes

Looking through some of the character attachments, for some parts I can’t find any attachments that dont have rig in the name.
Capture

could you try adding a new attachment to characters when they spawn? or adding attachments to a StarterCharacter? maybe it can be a clone of one of those rig attachments, but with a unique name. Then you can match the name to the Attachment in your Accessory

1 Like

Just curious, why are rig attachments special? Aren’t they all just attachments in the end?

1 Like

I suppose I could do that. Just out of curiosity though, may I ask why this behavior changed recently? It has been working fine for the past few years.

those attachments were never meant to be used with accessories, but it was just by chance that your accessories managed to get attached to the attachments you wanted. Recently the default character changed, and now it’s kind of just by chance that they don’t get attached to the attachment you want. It was never specifically implemented to work

2 Likes

This is currently affecting all of our games, and I’m not sure this would be an ideal solution. Adding clones of the attachments under different names just for the sake of morphs working again seems unecessary, and would easily scale up on memory usage and instance count when this used to work previously.

Is there no way the old behavior can be implemented to work or have a way to define what part an Accessory gets welded to? This is a crucial component of our games and it’d be kind of a bummer if we had to redo a lot of it just because it now becomes unreliable to use what has worked for years.

8 Likes

if you are creating your own accessories, you don’t need to attach them to attachments in the character. You can just weld them directly to body parts. Then you don’t need to create new attachments

I’m confused, how exactly would I achieve this?

During all these years where me and my team have been using accessories with attachments on the Handle to wrap around body parts properly this has always worked and welded correctly. When no attachment is specified, a weld isn’t created but the accessory gets placed in the avatar’s head.

Using the attachment has always worked to adjust position offset, rotation etc.

Resorting to welding this by ourselves would require us to redo all our morphs’ positioning. Why can’t this change just be reverted or at least give us the option to change where the AccessoryWeld welds to?

5 Likes

They’re special only because unlike attachments that are meant to be used for accessories, there are two RigAttachments per rig. It makes it unpredictable which attachment will be used with AddAccessory.


While it’s not as ideal as if we could specify which part to attach to with AddAccessory, making a custom function isn’t too difficult. The function below should work.

local function AddAccessoryToHumanoid(accessory, humanoid, priorityPart)
	local accessoryAttachment = accessory.Handle:FindFirstChildOfClass("Attachment")
	
	if accessoryAttachment.Name:sub(-13) ~= "RigAttachment" then
		--Not a RigAttachment, safe to apply normally
		humanoid:AddAccessory(accessory)
		return
	end
	
	local character = humanoid.Parent
	local characterAttachment = character:FindFirstChild(accessoryAttachment.Name, true)
	local weld = Instance.new("Weld")
	
	if priorityPart then
		local priorityAttachment = priorityPart:FindFirstChild(accessoryAttachment.Name)
		if priorityAttachment then
			characterAttachment = priorityAttachment
		end
	end
	
	accessory.Parent = character
	
	weld.Name = "AccessoryWeld"
	weld.C0 = characterAttachment.CFrame
	weld.C1 = accessoryAttachment.CFrame
	weld.Part0 = characterAttachment.Parent
	weld.Part1 = accessoryAttachment.Parent
	
	accessory.Handle:WaitForChild("AccessoryWeld"):Destroy() --Seems to exist immediately, but wait if necessary
	weld.Parent = accessory.Handle
end
4 Likes