x


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?

more ▼

asked Apr 11, 2011 at 08:59 AM

Rei gravatar image

Rei
25 19 14 20

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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

more ▼

answered Apr 11, 2011 at 09:09 AM

Skjalg gravatar image

Skjalg
1.7k 66 63 83

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. : )

Apr 14, 2011 at 09:23 AM Rei

The document should have explained it more that it will cause performance issue otherwise.

Feb 17, 2013 at 06:39 AM ZOwlz
(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Feb 08 at 03:00 AM

djee gravatar image

djee
0

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2993
x1469
x803
x125

asked: Apr 11, 2011 at 08:59 AM

Seen: 4459 times

Last Updated: Feb 08 at 03:00 AM