Game Development Reference
In-Depth Information
4.3 Physical player character
In this section we are going to create a character controller that with physical behavior. This
character can then be used for first person, third person, or even platformer input systems.
The idea is to have a capsule collider with a rigid body attached to it. This capsule is
going to be controlled by applying appropriate forces to it. To illustrate the physical character,
I am going to make a first person input system. Therefore, we need to have a capsule with the
main camera attached to it as child, and positioned at the top of the capsule. Let's consider that
our character has a weight of 70 kilograms, which can be set from the rigid body component.
Another important setting for the rigid body is to freeze the rotation on all axes, which means
that physics simulator cannot rotate the character but only move it.
Following the same methodology we used in section 4.2 with car driver, we are going to
make a character component that is totally isolated from user input. To control the charac-
ter, we are going to write a second script that takes user input and calls appropriate functions
from the character controller. Listing 47 shows PhysicsCharacter script, which we are going
to attach to the capsule to turn it into a controllable character.
Search WWH ::




Custom Search