- Home /
How can I get mesh height?
I am trying to get the height of my mesh in the standing position and then get the height of the mesh in the crouching position in order to determine how much I should shrink the collision capsule.
I have looked at a few videos on shrinking the capsule collider. The first way did it close to the way I want but it used the transform which shrinks the mesh as well as the capsule and it uses a ratio like 1/2 in order to shrink the capsule. This assumes that my mesh is half of the height when crouched as it is when standing. I do not want to assume that.
The second way manually enters in the correct values, heigth radius, center, based on the mesh you have. I like the first way but I need a way to get the mesh height to better estimate how much to shrink the collider and the collider only. The second way works almost perfect but I do not want to have to change the values every time I use this script on a different mesh.
I hope this is a clear enough explanation of what I want and why I need it.
Some thoughts I had:
Can I use mesh bounds?
Are the bounds that box that comes up around my mesh when I select it in the editor? If so the bounds do not seem to be an accurate representation of the actual mesh size. They are much bigger.
Is there a way I can use transform to get the height of the mesh?
When I play the game and crouch, the transform scale does not seem to change.
Your answer
Follow this Question
Related Questions
Editing Terrain Topology at Runtime 0 Answers
Strange problem with crouch script 0 Answers
Get height of a Mesh by X and Z coordinates 1 Answer
Simple mesh height alteration. 1 Answer
Camera Height-based crouch script 2 Answers