Calculate Character Height

My issue is I can’t accurately calculate the character’s height from the scale values BodyHeightScale and BodyTypeScale. I would like to avoid trying to yield for the humanoid to apply changes and then take the Y values of limbs.

I have tried the following calculation:

BodyHeightScale.Value*(BodyTypeScale.Value+5)

This equation is not accurate. I wish I knew how to calculate this because I’ve wondered for a long time.

1 Like

I think you forgot to factor in the proportions scale.

1 Like

GetBoundingBox might be able to help you.

1 Like
local function GetCharacterHeight(Character: Model): number
	return Character:GetExtentsSize().Y
end
print(GetCharacterHeight(script.Parent))

This would work, but it would also account for anything attached to the character model like accessory handles.

2 Likes

As far as I know scale is a scale, not the actual height. So you would need to multiply it by the characters default size to get the actual height. But I’m not quite sure what the formula would be.

You could try out a bunch of different characters and different sizes, then graph the results. So you can reverse engineer a formula to calculate the height, or maybe just use the graph as a lookup table.

1 Like

The default height is ~5.05 - 5.1 studs.

local function GetCharacterHeight(character: Model): number
    return select(2, character:GetBoundingBox()).Y
end
1 Like

Calculating Character Height

It sounds like you’re trying to calculate a character’s height using the BodyHeightScale and BodyTypeScale values. Unfortunately, these values alone may not provide an accurate representation of a character’s height.

One approach you could try is to use the GetExtentsSize method of the Model class to get the size of the character model. This method returns a Vector3 value representing the size of the smallest bounding box that can contain all of the parts in the model. You can then use the Y component of this value to get an estimate of the character’s height.

Here’s an example script that demonstrates this approach:

local character = game.Players.LocalPlayer.Character
local height = character:GetExtentsSize().Y
print("Character height:", height)

This script assumes that your character model is a child of the Players.LocalPlayer object. You may need to adjust this depending on how your game is set up.

Accesories will be able to modify the height then, I don’t think he wants that.

As the OP mentioned, he’d like an accurate calculation. This is the right way that I can offer him, btw GetExtentsSize would work too.

Calculating a character’s height solely based on its BodyHeightScale and BodyTypeScale values can be challenging as those values do not directly translate to a specific height measurement in studs. However, you can use some estimations to get a rough idea of the character’s height.

Here’s one possible approach you can take:

  1. Determine a reference height for the body type: You can use a reference height for each body type (e.g., R6, R15) to estimate the character’s height based on its BodyTypeScale value. You can obtain the reference height by measuring the height of a character with a BodyTypeScale value of 1. For example, the reference height for R15 characters could be around 6.0 units (assuming 1 unit is equal to 1 meter).
  2. Scale the reference height using BodyTypeScale: Once you have a reference height, you can scale it using the BodyTypeScale value to estimate the character’s height. For example, if the reference height for R15 is 6.0 units and the BodyTypeScale value is 1.2, you can estimate the character’s height to be around 7.2 units (6.0 x 1.2).
  3. Adjust the estimated height using BodyHeightScale: BodyHeightScale affects the proportions of the character’s body parts but doesn’t change the overall height. However, you can use it to adjust the estimated height based on the character’s body proportions. For example, if the estimated height based on BodyTypeScale is 7.2 units and the BodyHeightScale value is 1.5, you can adjust the height to around 10.8 units (7.2 x 1.5).

Keep in mind that this approach is an estimation and may not be accurate for all characters. The actual height of a character can also depend on various factors such as the length of its limbs, the shape of its body, and its animation rig.

Going off of what @8xD4n, @carbonscripts, @AlreadyPro, @SilentDevReal, said (why does it take 5 people?), I tried using GetExtentsSize().Y off of a BHS(BodyHeightScale) or BTS(BodyTypeScale) .Changed event. It did work surprisingly. I expected the humanoid to lag in changing the character size and so calculation would be made too early.

Going off of what @ketrab2004 said, I did the values 1.1 through 10.7, incrementing by 0.1 for BodyHeightScale. Then I used GetExtentsSize().Y to get the output at that value. I got the resulting graph.

The graph appears linear and the slope looks mostly constant, reflecting that.
If you omit value 2 for the average calculation, the average slope was 3.9135107743112707.

After testing with this new slope value, I found that the value of 4 was exactly correct for BHS. (My error in testing was a hat and animations).

1 Like

After much effort, I believe I have cracked the code with this formula.

BHS.Value*(4 + BTS.Value*math.pi/2) + 1

However, taking into account what @SubtotalAnt8185 said, it does appear BodyProportionScale can also change the actual height, although very small.

Finally I’ve seemed to calculate another linear slope value for BodyProportionScale.
This is my final formula.

BHS.Value*(4 + BTS.Value*math.pi/2*(1 - 1.2/math.pi*BPS.Value)) + 1

and simplified:

BHS.Value*(4 + BTS.Value*(math.pi/2 - 0.6*BPS.Value)) + 1

BHS is BodyHeightScale
BTS is BodyTypeScale
BPS is BodyProportionScale

14 Likes

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