The NeoCharacterController is a replacement for the Unity Character Controller which adds additional functionality such as:
- Moving platforms
- Interpolation between fixed framerate physics movement
- Arbitrary gravity and up-vector
- Height change, including jump-crouching
- Built-in pushing of rigidbody objects
- Reaction to impacts from rigidbody objects
- Physical interaction with other character controllers
- Curve driven slope speed modifiers
- Ledge friction property to allow sliding off ledges when overhanging
The NeoCharacterController is a kinematic character controller that uses a collide and slide technique to ensure smooth movement and collisions, while preventing fast movement penetrating through thin objects.
For more information on the properties that are exposed in the inspector see the NeoCharacterController Behaviour.
The other classes within NeoFPS refer to the NeoCharacterController using the
INeoCharacterController interface. This means that the character controller can be replaced with another implementation, as long as that implements the correct interface.
The Slope Friction property dictates how much of the downward movement is redirected down the slope instead of cancelled out. At a friction level of 1, any vertical movement into the slope will be cancelled out completely. At a friction level of 0, the character will slide down the slope due to gravity.
The Ledge Friction property specifies what happens when the character is overhanging a ledge. The NeoCharacterController has basic awareness of ground contacts that lets it know when it is in contact with an edge as opposed to a flat surface. If the character centerpoint is overhanging a ledge, and the drop distance is large enough, then the character will slide off the ledge depending on this setting. It can be used to prevent the character from hovering off the edge of obstacles unrealistically. If this value is higher than the slope friction, then the slope friction will be usd instead. This prevents sliding down a slope and then sticking on the bottom edge.
Rigidbody and Character Interaction
The NeoCharacterController can push dynamic rigidbodies, as well as react to impacts from rigidbodies.
The Low Rigidbody Push Mass is used to set a mass that the character can easily push. Any rigidbody at or below this mass will have a proportionate force exerted on it that will achieve the same effect. Above this mass, that force will drop away to zero as the rigidbody approaches the Max Rigidbody Push Mass. The Rigidbody Push property is the push power and can be experimented with to get the correct effect.
Similarly, the NeoCharacterController can also push and be pushed by other NeoCharacterController objects.
Gravity and Up-Vector
The NeoCharacterController operates using its own gravity value instead of the Unity Physics gravity. This allows for more flexibility to achieve a specific game feel. First person shooters often use a higher gravity than normal for character movement as it feels more realistic and less floaty.
The NeoCharacterController can also have its up-vector changed. This allows for features such as walking around on relatively small planets, or localised gravity zones. All features such as step height and slopes work the same as gravity and the up-vector rotate.
By default, the up-vector will be adjusted to face the opposite direction to gravity whenever the character gravity is changed. If the gravity is set to zero then the up-vector can be freely changed to allow for unlimited zero-g movement. A range of motion graph states will be added to take advantage of this in a future update.