Page URL: Humanoid.HipHeight
Issue Description:
We have no idea where HipHeight variable came from, and it would be nice if we were provided with a formula that works
Page URL: Humanoid.HipHeight
Issue Description:
We have no idea where HipHeight variable came from, and it would be nice if we were provided with a formula that works
I’m not sure I follow. HipHeight is the Humanoid.HipHeight property.
If this is a formula for calculating Humanoid.HipHeight
Height = (0.5 * RootPart.Size.Y) + HipHeight
then it is flawed because it would add more to itself, it would keep increasing.
Unless this is a formula for something else, let me know if that is the case.
Well, it says it calculates the overall height of the character, but I am a little out of touch and don’t know what the value for HipHeight usually is so I couldn’t calculate it. But I would assume, if I’m understanding it right, that the equation will result in a Height of about 6.
Edit: Yeah, I definitely don’t understand it. Listen to other people.
As stated in the article, Height is the height of the HumanoidRootPart from the ground.
I’m currently having a lot of confusion in figuring out what the Formula in the article is for. I assumed that it’s for calculating Humanoid.HipHeight but I could be wrong.
I don’t think you understand; Height is the distance from the ground to the center of the HumanoidRootPart, and HipHeight is the distance from the ground to the “hip” (the bottom of the HumanoidRootPart).
If you know how high above the ground the HumanoidRootPart should be, then you should be able to calculate the HipHeight, and vice versa.
@wow13524 what you said is true, but I completely understand @RuizuKun_Dev’s point. The formula by itself is not clearly understandable at the first sight, because most of us including me would associate height with character’s total hight (bottom of foot to the top of the head). This formula is useful when calculating the ratio and applying appropriate center height in case we have a custom character. The formula would be more understandable with different variable names, such as:
CenterHeight = (0.5 * RootPart.Size.Y) + HipHeight
-- or
HipHeight = CenterHeight - (0.5 * RootPart.Size.Y)
respectively
CenterHeight = LeftLeg.Size.Y + (0.5 * RootPart.Size.Y) + HipHeight
-- or
HipHeight = CenterHeight - LeftLeg.Size.Y - (0.5 * RootPart.Size.Y)
I think the meaning of CenterHeight should be explained separately just in case.
*Distance from the ground to the center of HumanoidRootPart.
@EssenceExplorer Thank you!
I am still confused, how the HipHeight is calculated.
HipHeight = 0
CenterHeight = (0.5 * RootPart.Size.Y) + HipHeight
-- or
HipHeight = CenterHeight - (0.5 * RootPart.Size.Y)
It’d still be 0
I guess it’s zero then, because there are no hips. In case hips are present, player would most likely get stuck in the ground.
Yes, that’s why I’m here and I’d like to avoid that.
How do I calculate Humanoid.Hipheight for a character?
Assuming you already know CenterHeight
, which is the distance from the center of the HumanoidRootPart to the ground, you can calculate it using this formula.
In the case of a normal R6 character, CenterHeight
would just be the height of a leg plus half of the height of the HumanoidRootPart. For an R15 character, you’ll need to traverse the Motor6D rig and sum up the vertical offsets for each to get CenterHeight
.
For a custom character, you should already have an idea of how high off the ground the RootPart should be for the character to look normal; use that idea to determine the CenterHeight
best for you.
EDIT
@RuizuKun_Dev most likely the easiest way for you to find the hip height is the following.
In an empty workspace, reduce Y-size of the BasePlate to zero (lowest is 0.05 actually, so such precision is necessary, subtract this value). Now position your character’s root part to vector (0, y, 0), because changing CFrame of HumanoidRootPart also automatically transforms all the other parts’ CFrames, as they are bound by Motor6Ds. Y-axis position of the HumanoidRootPart - 0.05 is very close to the actual size of the character.
To conclude this, both, R6 and R15 rigs are of similar height and their ratios are similar as well, which means the HumanoidRootPart vector’s length is around 3 studs. HipHeight to HumanoidRootPart ratio for both is very close to 2/3.
CenterHeight * 2/3 = your desired HipHeight.
In case you want higher precision, either multiplay CenterHeight by 2/3.1 or 2/3.15. Even higher precision, however, requires @wow13524’s method. I don’t think such rigour makes any difference, so it’s probably alright if you use rounded ratio of 2/3 and change height gradually up by 0.5 if really necessary.
Sounds like at the very least the code sample should have some more detail to it - logged it with the team!
Hi, @peraldon
It would be very beneficial to know exactly how the engine calculates Humanoid.Hipheight.
I would definitely be grateful for that, I am currently having issues with calculating Humanoid.Hipheight for custom characters and characters that are crawling.
I had to recalculate the HipHeight due to some manual manipulation of the character body parts.
This was the function I came up with, seems to work OK:
local function calculateHipHeight(character)
local joints = {
{
PartName = "HumanoidRootPart",
From = nil,
To = "RootRigAttachment"
},
{
PartName = "LowerTorso",
From = "RootRigAttachment",
To = "RightHipRigAttachment"
},
{
PartName = "RightUpperLeg",
From = "RightHipRigAttachment",
To = "RightKneeRigAttachment"
},
{
PartName = "RightLowerLeg",
From = "RightKneeRigAttachment",
To = "RightAnkleRigAttachment"
},
{
PartName = "RightFoot",
From = "RightAnkleRigAttachment",
To = nil
}
}
local hipHeight = 0
for _, entry in pairs(joints) do
local fromPos = entry.From and character[entry.PartName][entry.From].Position or Vector3.new(0, 0, 0)
local toPos = entry.To and character[entry.PartName][entry.To].Position or -character[entry.PartName].Size / 2
hipHeight += fromPos.Y - toPos.Y
end
hipHeight -= character.PrimaryPart.Size.Y / 2
return hipHeight
end
Hi Gawr Gura, I believe the reason for the addition of the leg height in the second formula is because HipHeight for R6 characters is actually the tiny space between the leg and torso/HRP. R15 HipHeight includes this “leg space”.
I don’t know about feet though.
I am aware there is a solution, but using the screenshot you posted, you can figure it out using simple elementary-level algebra.
for R15
Height = (0.5*RootPart.Size.Y) + HipHeight
HipHeight = Height - (0.5*RootPart.Size.Y)
for R6
Height = LeftLeg.Size.Y + (0.5*RootPart.Size.Y) + HipHeight
HipHeight = Height - LeftLeg.Size.Y - (0.5*RootPart.Size.Y)