r0128 r0128 - 11 days ago 8
C# Question

How to go about Manipulating a (capsule) collider in Unity3d C#

What would be the best way to adjust the height of a rididbody when for example my character goes into crouch position? would it be to get a reference to the rigid body and manually change the height etc, or would a mesh collider be a better option? Im open to any suggestions, I'm just curious what would be the best way to go about doing this.

Answer

Rigidbody itself doesn't trigger collisions, only colliders does so you should change the height of collider.

In my opinion cylinder collider is a better option then mesh collider because it produces less overhead, is easy to scale (for example by just changing height) and is quite good approximation of humanoid mesh.

So just keep a reference to cylinder collider attached to game object and changed height of collider whenever your character goes into crunch position.