Character colliders vs Rigid Body possible blend with both.

I’ve been getting to know unity through the user manual recently and up until know it’s been amazing except for the following part about character movement associated with character colliders and rigidbodies. So i’ve broken this down into three queries listed after the up coming Unity manual text.

Unity manual text
Character Controllers

You use Character Controllers if you want to make a humanoid character. This could be the main character in a third person platformer, FPS shooter or any enemy characters.

These Controllers don’t follow the rules of physics since it will not feel right (in Doom you run 90 miles per hour, come to halt in one frame and turn on a dime). Instead, a Character Controller performs collision detection to make sure your characters can slide along walls, walk up and down stairs, etc.

Character Controllers are not affected by forces but they can push Rigidbodies by applying forces to them from a script. Usually, all humanoid characters are implemented using Character Controllers.

Character Controllers are inherently unphysical, thus if you want to apply real physics - Swing on ropes, get pushed by big rocks - to your character you have to use a Rigidbody, this will let you use joints and forces on your character. But be aware that tuning a Rigidbody to feel right for a character is hard due to the unphysical way in which game characters are expected to behave.

My Queries
Part 1

I understand that great if you attatch the character collider to your character your able to slide along walls, detect steps etc(which is very cool)
but say for example your character is hit with a missile? Does the previous statement mean to say that because character colliders aren’t affected by physics the character wouldn’t be blown back by impact?

if so then how would you get your character to respond in such a way that he/she is blown back by the impact or is calling up a pre made animation the only way?

Part 2

The rigidbody will allow you to animate seperately and allow impact as it can be effected by forces however if you want to make your character slide along walls e.g (in a third person shooter) or to detect stairs you’d have to do what exactly??

part 3

I was wondering if there is anyway you can get the best of both in which your character detects things such as stairs, walls, etc but is also capable of being pushed, pulled and blown around.
This must be possible because games such as mass effect and others have the all around ability to do this. Is there anyway of blending the two so that you have character colliders and rigidbodies or can one or the other handle both physics and detection?

Hope someone can shed some light on the subject because the concept behind these two seems so confusing at the moment.

Many thanks in advance.

:shock:

There are many types of game where you want the character to be constrained by walls and other objects in the scene and track the shape of the floor. However, this doesn’t mean that you want realistic physical motion with gradual acceleration, character able to fall over, etc. A CharacterController is a sort of semi-physical object which is useful in situations like this.

It is possible to add a rigidbody to a CharacterController object, but with its isKinematic setting enabled. This means that the rigidbody is available, but not currently involved in physics simulation. However, you can turn isKinematic off at any time from a script. You would do this just as you were about to apply a force representing an explosion, say. The character would then have realistic physical motion until you disable isKinematic again.

This is a pretty good way to get the best of rigidbody physics and CharacterController behaviour, but the switch is not automatic, of course - you have to do it as necessary using a script.

Aaaaaaaaaaahhhhhhhhhhhhhh!

It makes so much sense now.

Okay cool now I understand.
Thanks allot andeeee for helping to understand the differences and what i’d be looking for.

Are there any pre-made scripts for something like this on unity’s website simply for switching between isKinematic enabled and disabled?

I presume even if a the script allowed that capability you’d still have to code different cicrcumstances in which isKinematic is enabled and disabled for example when a raycast from a weapon is pointed on your main character and fired?

Switching isKinematic on and off is as simple as assigning true or false to it. As you say, the circumstances where you would do this are specific to each game. Generally, you need to switch isKinematic off just before you apply a force of any kind (explosion, punch, etc) and switch it on again when the character regains control. Since the physics simulation is not entirely predictable, you will sometimes need to make sure the character can’t get stuck somewhere as he lands.

Thanks for the advice andeee it’s been very helpful.
Time to go put this new found knowledge into action.

:stuck_out_tongue:

hi all
when i add rigidbody and character controller and move then my character go below of terrain.why?
when my character , collision with enemy character then enemy character Rear digress.why?
how can i set that enemy character dont Rear digress?
thankful.