I’ve been trying for a good long while to apply an accessory’s offsets retrieved from the metadata table returned by :GetCharacterAppearanceInfoAsync() onto an accessory’s attachment point. I’d like to achieve this without using AccessoryDescription objects as I want to then use the functionality to apply offsets and such onto custom accessories or accessories that don’t link to any AssetId. The end-goal is to replicate how Roblox applies their accessory offsets so that when player’s edit their outfit, they are able to make transformations that could be similarly applied to the Roblox avatar editor.
I’ve already tried many CFrame manipulation methods to get it to work but I just can not figure out the way Roblox does it. They would always be rotated some weird way or be positionally offset slightly off.
Roblox’s offsets:
My attempts (complete failure):
This was the last piece of code I tried writing to get it to work and is what the pictures were using.
local posOffset = Vector3.new(metadata.position.X, metadata.position.Y, metadata.position.Z)
local rotOffset = Vector3.new(metadata.rotation.X, metadata.rotation.Y, metadata.rotation.Z)
-- Apply the rotational offset
attachment.CFrame *= CFrame.Angles(math.rad(rotOffset.X), math.rad(rotOffset.Y),
math.rad(rotOffset.Z)):Inverse()
-- Apply the positional offset
attachment.Position -= posOffset
-- Apply the scale
mesh.Scale *= metadata.scale.Y
-- THIS IS COMPLETELY OFF????????
The positional offset should’ve been really easy to apply but for some reason my attempts were always off either slightly or completely. As for the rotational offset, I could never figure out a reasonable solution that would also leave the positional offset intact. I feel like I could make use of CFrame:ToWorldSpace() or CFrame:ToObjectSpace() but I still don’t have a solid idea on how those would be applied in a case like this.
I would appreciate any help or just any solutions to this issue.