- Home /
Difference between a rigidbody and a character controller?
Ostensibly I understand: A Rigidbody will be affected by physics and, by default, collisions with other rigidbodies.
A character controller is kind of a blank slate: Roll your own physics for this object, plus some nice functions (.isGrounded() etc.)
But when do you use each one? For example, in a current 2D project I have a characterController for my player character and use cc.Move() to get him around. Should I also use a cc for my enemies? Or are they better off being rigidbodies? Why?
Also, when moving a rigidbody, what's my best option? Translate seems wrong: Do you just add forces to the object instead?
I guess I'm just a little foggy and when you;d use each one and why, especially in relation to 2D games.
Answer by whydoidoit · Jan 28, 2013 at 02:59 AM
You can use a CharacterController for anything that's supposed to be a character in the game (player or NPC_, it can work quite well. You'd use a rigidbody if you wanted Physics, you probably don't want physics for people who are standing upright - but it can be done!
CharacterControllers automatically handle lots of cool things like platforms and trying to "unstick" characters from each other - but it's a bit jerky. Personally I keep trying to use them, then write my own because it's not easy to get it to do exactly what I want, but if you are happy with the movement and it fits your style of game then go for it.
I'd only use physics if you need it (cars, rocks, balls etc etc).
As far as "write my own", you mean by attaching a box collider and going from there?
What's the best way to move a character in that situation? I understand Translate is not a good idea because you can move something inside another object.
Yeah, in my current project I have a "kinematic" rigidbody so I can move the capsule collider at low cost. Then a $$anonymous$$eepApart manager that gently moves people out of the way of each other and important objects. A turning script which chooses a route around obstacles, a path follower that gives the route and scripts for animation based on movement.
For instance I have a bunch of people queueing for things (like buses, honest) and a CharacterController would have them glitching all over the place because they need to be together. Plus I'm simulating people walking on a street where you don't often see people backing up 2 ft when then approach someone else, they kind of sidle around.
For me making a distinction between avoiding other characters (and pinch points) then having a separate major obstacle navigation that totally ignores people was a really good balance.
Your answer
Follow this Question
Related Questions
Can't use Rigidbody or Character Controller 0 Answers
Stop objects from going through each other with rigidbodies 1 Answer
How Character controller can push another character controller? 0 Answers
Question about pushing objects, "Animate Physics" and Rigidbodies 0 Answers
Which is more demanding on a computer, lots of CCcharacters or lots of Rigidcharacters? 1 Answer