CharacterController and non-capsule collisions

Hello!

I’d like to use CharacterController for a box-like object (tank, for example).
I’ve experimented and googled a lot,
but haven’t yet found the right way to make it collide with something else apart from the built-in capsule (the one that is built-in into the controller).

…How should I approach the problem?

thanks,
Slav

have you tried the box collider?

Otherwise you can change the axis of the capsule which normally stands up.

Also check out the multiple colliders on the unity website, I think you can find that page with google.

You can’t change the shape of a CharacterController. If you want differently shaped collisions for an actor/player object, you’ll have to use rigidbodies and a different primitive collider and roll your own movement scheme.

If you want ive been working on a custom character controller that is using kinematic collisions. It wouldn’t take much work to change the object over to a box collision instead of a capsule if you need it. Otherwise if you want to rip it apart and replace my capsule stuff with box stuff then. I will post it here but this is still un-optimized code and slope and stairs are not working, also its sending the wrong collision flags at the moment, so here is the code 600179–21328–$capCharacterController.cs (6.19 KB)
but if you want private message me in like 2 weeks and i should have that code finished and i can write it to work with a box collider for you.

Hope that helps
The Captain

CaptainMorgan, thanks!
Does it work ok with static colliders and other moving capCharControllers in the same scene?

Now I need to have a look at the code :).

I get a null reference in edit mode:

CaptainMorgan, your code helps me a lot - thank you very much for sharing this!
I would be completely interested in the final version of capCharController :).

I see that you use CapsuleCast() (which I haven’t thought about),
and I am not sure BoxCast() exists - so how should I approach replacing a capsule with a box?

I was thinking about using Rigidbody.SweepTest() to test collisions, but haven’t tried to do it yet.

Did this ever get completed? After working with the physics system, I decided I want to try and use a kinematic controller for my characters. If you don’t mind sharing the final version I would love to take a look at it since I am rolling my own in the interim.