How could I make it so skinned mesh bones follow a basepart's cframe?

Right now, I am trying to create an interesting visual effect, where the tabard that extends past the leg moves with the leg.


A posed example above…

But how would I create code that would do this..? I could try using smartbones but I want to see if this would be a better, cleaner solution..


yea.

1 Like

Bones have a Transform property like Motor6Ds which you can set every PreSimulation or so. I think it might be as simple as this:

-- PreSimulation is the step before Roblox applies Motor6D transforms
RunService.PreSimulation:Connect(function()
    tabardBone.Transform = leftHip.Transform
end)

The rotation applied by Transform might change depending on C0/C1 though, that requires some extra CFrame math that I may have forgotten how to do…

1 Like

oh very interesting ill have to check this out.. tomorrow, but ill be sure to update u on how this turns out!! ty

1 Like

It appears you’re using R6, so why don’t you just separate the mesh and use WeldConstraints instead of using a skinned mesh?

I’d imagine that splitting it would also be more optimized than using a skinned mesh.

I wouldn’t say so. That’s extra draw calls when it could just stay as one mesh; separating it would be less performant in that case.. especially because there’s more assets for the client to download. More to download means more memory, and more parts added to an assembly means more for Roblox’s physics solver to worry about.

I guess, I still haven’t looked too far into rendering, all I really know off the top of my head is that skinned meshes are much more expensive than static ones (framerate-wise) due to all the math relating with weight paints and bone offsets and whatnot.

1 Like

That used to be my very old method for stuff like this, but for the sake of experimenting, especially with new visual designs, simply I just think this looks cleaner.

And like how @Starveldt, using one mesh instead of 3 total meshes is more optimized, regardless if it has bones or not, ALTHOUGH I do want to say the difference is minimal, its a drop of optimization differences in a big bucket of crappy roblox servers and low-end client devices.

2 Likes

OK, Small update on this, It works but now how i’d want it, it seems to be bending to the sides rather than in line with the leg.

Right, that’s the issue. Since your Bone and Leg Motor6D have differing C0/C1s, they rotate in different ways. It’s hard to understand so I made a little repro of what I mean.

Take these two rigs:

The one on the left is R6, and the one on the right is R15. Their joints are different in a few ways, but I’ll be moving their hips in this particular example.

Here is the R6 rig’s “Right Hip” joint:

…and, here is the R15 rig’s “RightHip” joint:

You’ll notice that the rotation on C0 and C1 on the R6 rig’s “Right Hip” is 0, 90, 0, meaning it’s rotated to our right, while the joint on the R15 rig is not rotated whatsoever; so, it’s completely in-line with the front of the character. I also made a little test script to tween the two, but here’s the general loop:

RunService.PreSimulation:Connect(function(delta: number): ()
	if tweenDelta < TWEEN_TIME then
		tweenDelta += delta
	end

	local tweenAlpha: number = TweenService:GetValue(
		math.min(tweenDelta / TWEEN_TIME, 1.),
		Enum.EasingStyle.Sine,
		Enum.EasingDirection.Out
	)

	local transform: CFrame = CFrame.Angles(
		.5 * math.pi * tweenAlpha, -- Pitch (up/down)
		0., -- Yaw (left/right)
		0. -- Roll (tilt)
	)

	hipR15.Transform = transform
	hipR6.Transform = transform
end)

You can see from my intent, I would like the legs to rotate up 90 degrees. But, plugging this in:

You’ll see that, despite the Transform being applied the same on both rigs, the R6 rig’s leg goes to the side.. which is not quite what we want. So, we’re going to need to translate the Transform of the tabard bone a little…

So, with how you’re currently handling it, it looks like this:

tabardBone.Transform = transform
hipR6.Transform = transform

And, here’s my fix:

tabardBone.Transform =
	tabardBone.CFrame.Rotation:Inverse()
		* hipR6.C0.Rotation
		* transform
hipR6.Transform = transform

Works great for me, try it yourself and tell me how it goes
Edit: Just doing tabardBone.Transform = hipR6.C0.Rotation * transform also works; inversing tabardBone.CFrame negates the tabard bone’s original orientation, so it’d be exactly in-line with the leg… which you might not want in some cases

1 Like

Ok so, this is really insightful, but It is not doing the desired result and I am not sure if it has something to do with the rigging or the way I am trying to connect it, because right now it just scrunches up and then returns to normal to repeat, (albeit this is namely due to me using the tween you made to test if it could be in align with leg movement



as well as applying the transform to the leg

Something tells me that your rig is a little more complex than I’m imagining…

Would you be able to send the bone structure, and the exact bone from it that you’re trying to move?


Perhpas it might be, but if its worth anything Ill rerig it and try your method again since it does look like it CAN work, and its my end issue, tysm tho.

1 Like

Oh, yeah, that looks more smartbone-ready than what my solution is lol

I was imagining a structure similar to the R6 rig, not something meant for deformation that complex

Yes yes, no worries Ill still attempt it with a rerig but I got another busy week so I doubt ill respond.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.