Resizing a capsule collider at runtime

Hey guys,

I am working on character controllers in ECS and currently implementing crouching. I would like to resize the collider, but I am not seeing being able to do so, aside from creating a new collider every frame the crouch state is animating. Is this really the only option? Thanks!

Yeah, unfortunately there is not option other than to set a new collider. But a small optimization might be to store 2 colliders, original one and the crouching one, and then just switch between them. That way you won’t need to instantiate it every frame…

1 Like

If the collider is a simple one, e.g. a capsule collider, you can tweak the underlying geometry. Check out the 5b. Change Collider Size in the samples. The associated script will act as a reference.
@petarmHavok 's suggestion is the most generic approach though.

Looks very promising, thank you!

Hi, maybe this will help other people with the same question.

A difference box collider, capsule collider has the possibility of modifying the radius and height.

the code to access this is:

8533454--1139423--Screenshot 2022-10-22 223928.jpg

1 Like

This has nothing to do with Unity Physics. Your suggestion isn’t helpful here.

2 Likes