Making a Character Controller

So because the default CharacterController is useless (see: http://www.youtube.com/watch?v=gA8Ns_KMxv0) because it uses a capsule collider and there's no way to change that (WHY?!? Sigh.) I figured I have to go ahead and make my own Character Controller from scratch. If there's an easier way please do tell!

(From youtube page description:) As a CharacterController moves to the edge of a square platform, the curve of the capsule causes the character to move down causing the model to appear to sink into the platform.

So, I figure I need a kinematic Rigidbody attached to my character (it shouldn't be affected by physics, only collide with solid objects (so that it doesn't fall through ground etc). Does that mean I have to build a collision system from scratch, since afaik, kinematic rigidbodies do not collide?

You can add your own sliding effect so it falls off and doesn't hang on the sides of objects.

1 Answer

1

Does that mean I have to build a collision system from scratch, since afaik, kinematic rigidbodies do not collide?

Well you certainly should take a look into the volume collision tests unity offers. Ironicly they are Physics.SphereCast and Physics.CapsuleCast but you might be able to do something custom with Physics.RayCast. These methods can ease your movement code so your character doesn't walk inside colliders. Maybe you could just do a raycast from the left and right sides of your character and stop gravity from being applied if it hits something? Sounds like an easy fix for the otherwise working controller. You should also know that Physics.SphereCast has a potential bug.

I haven't tried this but could you perhaps parent a box collider to your characters "feet"?

What you could try to do is otherwise make the capsule collider a bit bigger, or just accept it intersects a bit. It is quite common in triple a games that models intersect with surroundings. You can do a bit of research on your favourite games yourself. Maybe you're too concerned about it?

For sympahty, I also wish the character controller was a bit flexible. I had to tackle this problem for a project :) http://answers.unity3d.com/questions/35781/can-i-use-character-controller-with-animal-characters-such-as-a-crocodile