- Home /
Should a Character Controller attach with Rigidbody?
http://unity3d.com/support/documentation/Manual/Physics.html
somewhere in the reference it says: "You should never move a Static Collider on a frame by frame basis. Moving Static Colliders will cause an internal recomputation in PhysX that is quite expensive and which will result in a big drop in performance. On top of that the behaviour of waking up other Rigidbodies based on a Static Collider is undefined, and moving Static Colliders will not apply friction to Rigidbodies that touch it. Instead, Colliders that move should always be Kinematic Rigidbodies."
A character controller is derived from a collider, So is that mean I should always attach a kinematic rigidbody to the character controller?
Answer by Skjalg · Apr 11, 2011 at 09:09 AM
Yes.
If you intend to move the collider around a lot it is recommended to also attach a kinematic rigidbody to it.
http://unity3d.com/support/documentation/ScriptReference/Collider.html
well as it's the collider for player object, it is going to move around. It wasn't that obvious that we should add a kinematic rigidbody to it. I'm glad to get a confirmation from you experts. : )
The document should have explained it more that it will cause performance issue otherwise.
Answer by djee · Feb 08, 2014 at 03:00 AM
I tend to disagree and say "No".
The character controller (CC) - at least as implemented in PhysX, that is a kinematic CC - is a very specific piece of code working alongside (but outside of) the main physics simulation (rigid body dynamics). Although the CC do use a capsule collider, the collision is typically performed "by hand" in the CC code rather than automatically through the physics simulation like other colliders.
The remark about a kinematic rigid body being needed with a collider when you move the collider (i.e. change the transform directly, instead of applying forces to a rigid body) is mainly directed at other objects like a moving platform you would have in a typical platformer game. Indeed in this case the collider is by default part of the single "static" rigid body implicitly created by Unity to model all static objects in the simulation. So if you move it you invalidate the collision cache of all those objects at once, hence the performance warning. But in the case of the CC the collider is not part of the simulation, and is merely used as a data structure to remember the shape of the collision the CC has to take into account into its own specific collision routine.
I may be wrong about all this, as I am quite new to Unity. However I do know well about physics engines in general, and have written my own CC and physics engine, as long as studied the code of Bullet Physics (another physics engine competing with PhysX) and the CC of Doom3. If anybody has more insight about the actual Unity implementation please feel free to correct me.
For more informations about character controllers you might want to read the CC notes in the PhysX SDK or have a look at an actual working implementation in the Doom3 GPL code.
I am somewhat familiar with bullet physics as well (implemented it in my unity engine for threading reasons) and, now that I'm using the new PhysX, am wondering the same thing.
The real question is whether Unity uses PhysX's character collider or if it implements it's own which uses a standard capsule collider. This really should be explicitly stated somewhere.
Your answer
Follow this Question
Related Questions
Character Controller Jittering 0 Answers
Moving a player on a rigidbody platform that can collide 2 Answers
How to make a ragdoll not rotate but still be non kinematic? 0 Answers
jet pack physics with character controller 1 Answer
How to use character controller to push down hinge joint properly 1 Answer