[R15] Anyone Know How to Properly Reset HipHeight When Replacing Limbs with New Package Pieces

So I have created a script to replace the limbs of a character dynamically. I’m only actually using this once - on spawn. I’m just swapping MeshParts for MeshParts after having gotten the default R15 folders for each limb of the Boy package, then calling Humanoid:BuildRigFromAttachments(). The problem is that I end up with this situation:

image

Notice that you can’t see the feet of the model? The hip height is still at 1.35, which is fine for the default blocky character but not so great for other packages.

Could I just wear each package on my own character, spawn in game, and copy the hip height? Sure. But the problem is that I need to be able to have this system be robust enough that not all parts come from the same package - or even any official Roblox package (it can be used for custom MeshParts).

Does anyone know how to dynamically calculate hip height correctly? Or is there a simple function for it that already exists and I just have managed to completely miss?

Also, what exactly does Humanoid.HipHeight relate to in an R15 rig? I know it is the height offset from the ground for the Torso in R6, but its R15 definition is not listed in the Wiki…

All productive input is appreciated! :slight_smile:

8 Likes

Well - when I tried swapping out 3 packages, with the character height scale (BodyHeightScale) set as 1, all 3 showed a HipHeight of 1.35.

When adjusting the character height scale, I got the following values:
0.95 = 1.283
1.00 = 1.35
1.05 = 1.418

Of which there’s a ~0.0675 slope between each 5%.Changing the slider NumberValue in the Humanoid also seems to adjust its HipHeight.

Any specifics about the model in the picture? 1.5 is way over the 3 values I posted earlier in this post, so either I’m misunderstanding the situation, or the feet should be floating. :thinking:

I’m sorry. I meant 1.35, I mistyped.

I figured out an answer.

So, apparently for R15, hip height is the offset from the ground to the bottom of the HumanoidRootPart. So, the calculation is actually pretty simple. Here is a function to do this:

function recalculateHipHeight(character)
	local bottomOfHumanoidRootPart = character.HumanoidRootPart.Position.Y - (1/2 * character.HumanoidRootPart.Size.Y)
	local bottomOfFoot = character.LeftFoot.Position.Y - (1/2 * character.LeftFoot.Size.Y) -- Left or right. Chose left arbitrarily
	local newHipHeight = bottomOfHumanoidRootPart - bottomOfFoot

	local humanoid = character:FindFirstChildOfClass("Humanoid")
	humanoid.HipHeight = newHipHeight
end
23 Likes

I should also say that this may be a bug - apparently calling Humanoid:BuildRigFromAttachments() will reset the hip height to 1.35. Not sure if this is intended behavior. Any comments from client team would be much appreciated :slight_smile:

1 Like

Aha, makes sense. Tested this on a large-scale game, and it does not cause that much server strain. Thanks!

It works great! You need to make sure animations (At least for legs) aren’t playing though.
Obvious reasons :wink:

I swear it used to fix our HipHeight automatically.
Could it be a bug? Did anyone report it yet?
Maybe it’s related to the new proportion settings we’ve been seeing.

Very true - Guess I forgot to include that I had already ensured that at this point in my code :joy: Thank you for pointing it out!!

I was actually having this problem on a game I worked on called Robot Simulator. The robots had really weird hipheights after building rig from attachments and they looked like they were standing in mid air for a sec then fell down. Did that about 3 times while in air after jumping. Thank you for this solution!