Non-upright characters

I started a project using the default character controller and have come back to improve it but realised I cannot change the shape of the capsule collider that comes with it.

Our models do not fit into the vertical capsule and adding more colliders doesn’t seem to help.

I thought of writing a replacement character controller but it seems that I have to add a rigid body to get any meaningful collision info, and applying forces doesn’t seem to work when the bodies are on the ground. (I’d also rather have more control
over the characters so they don’t fly out of the level)

I feel I must be missing something and am left wondering what other people use to control their characters if they cannot use the default CharacterController.

Any ideas?

Thanks in advance.

Why would you need to use forces? Can’t you set the rigidbody to be kinematic and use simple scripting to move it? You would still receive collision information, and will have total control of your character…
Plus, it CAN be effected by physics in case you like it to be, just by setting isKinematic to false when you want to…

Although it won’t help you receive collisionFlags from the controller that will take your extra colliders into account, when checking the collisionFlags you can add your own tests to see if your colliders hit anything… At least you won’t be rewriting the entire controller from scratch, just adding to it.

Thanks very much for your comments.

Unfortunately our world geometry uses static colliders so by setting the rigidbody to isKinematic we lose collision detection again. According to the manual, only (non-kinematic) rigid bodies will be detected when colliding with a kinematic rigid body.

http://unity3d.com/support/documentation/Manual/Physics.html

This makes sense from a rigid body standpoint in that collision information is only generated when one or more of the colliding objects is to be physically affected. However, I’d like to be able to receive collision info without either object being affected, which does seem to be how the CharacterController works during its Move step.

I’ll keep trying. It’s odd that you can’t just whack a collider on an object and receive collision info when it comes into contact with other colliders.

Thanks again. Any further thoughts or suggestions?

At the risk of blowing my own horn:

http://forum.unity3d.com/viewtopic.php?t=9476

In general the FPS controller doesn’t buy you much except for "grounded"ness. The faux gravity code shows how you can arbitrarily set a given object’s UP vector.

You can use all the standard physics stuff except gravity, which is hardwired to go in the -Y direction.

podperson: Awesome job man. You made my day :slight_smile:

Quornian:

Oh, well that is a problem. Forgot that little fact. Guess I’m rusty on my physics :confused:

Well then you have some options I can think of… But they are not perfect.

First - since the physics engine still works - it simply will not let you move your character if its colliders collide with something like a wall… You might not need collision detection. What are you planning to do with it anyway?.. :slight_smile:

Second - Instead of OnCollision events you can probably use OnTrigger events… It will not give you the exact place the so called collision happened, but if you add 4 boxes for example that are marked as triggers and have kinematic rigidbodies on them to your character (surround your character with them), you will receive an event when one of them “collides” with something.

Third - You can use Physics.Raycast.

And fourth - You can use the Physics class, specifically CheckSphere, CheckCapsule and OverlapSphere to check for collisions on your own.

Obviosly for increased performance you can mix and match… Maybe Check for basic collisions using triggers, and then to get more information raycast only in that specific area to check where exactly the collision accured. And so on…