[DEPRECATED] Character Movement - Advanced kinematic character controller

Character Movement has been developed as a comprehensive alternative to Unity’s built-in Character Controller.

It allows for more realistic character behavior, complete customization and robust ground detection following the same workflow (Move / SimpleMove) for seamless integration into existing projects.

It can be used for any kind of character (player or AI controlled) and for a wide range of games like, platformer, side scroller, first person, third person, adventure, point and click, and more!

It offers full control over the update and simulation timestep perfectly suitable for tick-based simulations.

  • If you are looking for a complete character movement package with Character Movement included, check out Easy Character Movement 2

FEATURES

  • Kinematic character controller.
  • Work the Unity’s way, simply call its Move, SimpleMove methods, just like Unity’ Character Controller.
  • Cinemachine-based First and Third person examples.
  • Robust ground detection based on real surface normal.
  • Slope Limit Override lets you define walkable areas per-face or even per-object.
  • Configurable walkable area (perchOffset) lets you define the character’s ‘feet’ radius.
  • Capsule-based with Flat Base for Ground Checks option. This avoids the situation where characters slowly lower off the side of a ledge.
  • Ground constraint, prevent the character’s being launched off ramps.
  • Configurable Plane Constraint so movement along the locked axis is not possible.
  • Auto-stepping preserving character’s momentum (i.e. Its stride).
  • User-defined gravity and up vector for mario galaxy like effects.
  • Physics interaction.
  • Character vs Character interactions.
  • First-class transparent (without further steps needed by you) platforms support, be it animated, scripted, physics based, or even fully simulated objects like vehicles!
  • Collision and Grounding events.
  • Network friendly. Full control over the update and simulation timestep, perfectly suitable for tick-based simulations.
  • Flexible and customizable behavior through callbacks.
  • Simple to use complete API.
  • Full source code included.
  • Garbage-Collector friendly, no GC allocations.

FAQ
What is a character controller ?
A Character Controller allows you to easily do movement constrained by collisions without having to deal with a dynamic Rigidbody.

A Character Controller is not affected by forces and will only move when you call the Move function. It will then carry out the movement but be constrained by collisions.

In the past, games did not use a ‘real’ physics engine like the PhysX SDK (Unity’s underlying physics engine). But they still used a character controller to move a player in a level. These games, such as Quake or even Doom, had a dedicated, customized piece of code to implement collision detection and response, which was often the only piece of physics in the whole game. It actually had little physics, but a lot of carefully tweaked values to provide a good feeling while controlling the player. The particular behavior it implemented is often called the ‘collide and slide’ algorithm, and it has been ‘tweaked for more than a decade’.

The Character Movement is an implementation of such an algorithm, providing a robust and well-known behavior for character control.

Who is this for?
For developers who are familiar with programming and 3D math and want to build their own game mechanics using a comprehensive character controller as their foundation.

For developers who are willing to replace Unity’s Character Controller with a robust and feature-rich alternative but following the same Unity’s workflow they know and love!

For developers who want to learn how to build common character movement mechanics such as walk, jump, fall, crouch, first person, third person controllers and are already familiar with Unity and programming.

What is the difference between Character Movement and Easy Character Movement 2 ?
Character Movement is a general purpose character controller analogue to Unity’s Character Controller aimed at developers who prefer to build their own character movement and game mechanics from scratch using a comprehensive character controller as their foundation.

Easy Character Movement 2 adds a higher-level layer on top of the Character Movement component implementing a highly-featured Character-based classes and is aimed at developers who prefer a more complete character movement system out-of-the-box.

Additionally, ECM2 includes over 40 examples, ranging from using the new input system custom actions, PlayerInput component, first person, third person, target lock, twin-sick movement, dash, slide, ladders, AI, Cinemachine, Bolt, and many more!

Can I use URP/HDRP?
Yes, Character Movement doesn’t do any rendering, it’ll work with any render pipeline. The demos are made using the Built-in Render Pipeline, as it’s still the most common denominator, but you can use any RP you prefer.

HELP AND SUPPORT
Getting Started Guide
WebGL Demo
User Manual
Walkthrough
API Reference Download
Email

IMPORTANT NOTE ON PACKAGE DEPENDENCIES

The Character Movement component does not require any external package, however its Demo and the First/Third Person examples require the Cinemachine package to work.

Please make sure to install the Cinemachine package into your project when importing demos and examples.

SCREENSHOTS

ASSET STORE PAGE
Character Movement

It’s live at Unity Asset Store, hope you like it!

Please let me know if you have any questions.

Cheers,
Krull

Hey!
I have a fully developed game using the Default Unity controller, which obviously isn’t ideal, running into lots of limitations and wanna move away.
How hard would it be to move an Existing full game using the Default controller to this controller? Are all the Forces and whatnot the same? Or am I likely gonna need to make a lot of adjustments to get it to work the same?
I wanna replicate the same controller I already have, so same speeds, jump height, and so on as closely as possible.

Hi @killer1171090 ,

Thank you for your interest in Character Movement.

About your question:

Definitely, replacing the character controller with character movement is pretty easy.

In your case, since you are computing all forces and movement code should behave the same, however with CC you pass the displacement vector (e.g: updatedVelocity * Time.deltaTime) to its Move function, while with CM you pass the velocity (e.g: updatedVelocity) to its Move function.

Now depending on your game requirements you could need further changes in case you are updating your character controller in Update method and using / expecting heavy physics integration, in that case you will need to update your character in sync with the physics engine tick.

All this is explained in the included walkthrough.

To illustrate it better, please take a look at the attached script, this is Unity’s Starter Assets third-person controller BUT replacing the character controller with Character Movement so you can get a better look of how easy it is to port.

Let me know if you have any further questions.

Regards,
Krull

7837464–993318–ThirdPersonController.cs (11 KB)

1 Like

Well that was suprisingly easy, I changed the CharacterController on the player and the script to CharacterMovement, Replaced The CharacterController.Bounds with CharacterMovement.Collider.Bounds which seems to be the same.
Removed all the Time.DeltaTime’s and done.
In my case i had to also move some movement code i had in Fixed update to the Update method to get the same forces, but thats specific to my project i have a fairly complicated and precise movement system.

Still testing things, but it looks like that was it!

1 Like

One other questions, does this controller support rotation? I think i saw it somewhere before but i couldnt find any documentation on it.
like Can i have my character walking on walls and stuff?

Hi @killer1171090 ,

Great! Glad to hear you were able to replace the character controller with Character Movement!

Sure, you can freely rotate the character and gravity to create a mario galaxy like movement, however please keep in mind to implement this, your movement should be relative to its new up axis.

1 Like

Hey,
Does Character Movement supports interpolated physics ? I use it a lot in my projects to avoid flickering.
Thanks :slight_smile:

Hi @corjn ,

Absolutely. As you can see in the demo scene, all green objects are real physics objects (Rigidbodies, Hinge Joints, Spring Joints, etc).

However in order to make your character movement in sync with physics, you will need to move your rotation and movement code from Update to a LateFixedUpdate. This LateFixedUpdate is just like the Unity’s MonoBehaviour FixedUpdate, BUT its executed AFTER internal physics update, so the character can read the world’s current state.

You can find a complete explanation and examples in the walkthrough and obviously included examples and walkthrough companion examples within the package.

As part of the following v1.0.1 minor update, I’ll add a helper component PhysicsUpdateBehavior that extends the MonoBehaviour adding a LateFixedUpdate so it will be even easier to do physics integrations.

eg: PlayerController : MonoBehavior → PlayerController : PhysicsUpdateBehavior

And put the code you regularly put on FixedUpdate in the new LateFixedUpdate.

Kind regards,
Krull

Minor Update Released:

VERSION 1.0.1

  • Added a ‘Getting Started with SimpleMove’ guide and example.

  • Minor bugs fixed.

Would it be possible to offset the physics capsule from the root Transform instead of offsetting the root Transform in CharacterMovement similar to the CharacterController.center property? I took a look at the source code but couldn’t find anything that would appear to do that. I use that particular property in order to shift the character body so that both the CharacterController’s hidden collision capsule and the movement capsulecast are both located at an offset from the character’s root transform during runtime.

Hi @tsupra88

I am afraid it’s not possible, could you develop a bit about what you’re trying to achieve? If willing to prevent collisions, there are several options included.

Regards,
Krull

Current, I have a Player entity that can offset the Unity CharacterController component center property (local position offset from the Transform that the CharacterController component sits on. The internal CapsuleCollider generated by the CharacterController component as well as the Physics CapsuleCast that occurs during the sweep phases can be freely updated relative to the Transform pivot by providing the center property offset. This allows for the capsule to be spaced at any point within a box volume, but the capsule itself will dictate movement collisions as well as other objects falling and hitting that kinematic Rigidbody Collider. For example, if I have the capsule +1meter in front of the Transform’s pivot point, it can run into a wall and prevent movement. If I move that capsule back to the 0,0,0 point, I can then move the character rig forward by 1 more meter. The Radius and Height on the CharacterMovement component work as I expected, but the Center property is critical to the project I’m working on.

The rest of the code I have currently hooks into the CharacterController component and alters its center value at runtime where I can move the character capsule around a box platform. Shifting the center value about will determine what it is allowed to hit/dodge. This allows for both the platform to be controlled and moved, as well as the character standing on the platform. However, only the character will bump into walls when Move() is called. Maybe the attached image will make the issue more clear. The wireframe is offset from the Transform point and will handle collision when moving as well as represent what other objects will hit. The 2nd part with the objects being hit is not too much of an issue since I can just move the CapsuleCollider component center. The issue is the Move() command where I currently can’t do that same offset with CharacterMovement (at least I can’t find it if it is there).

I see, while the current version does not support offset, it already includes a vast set of collision detection and ground detection (ie. Raycast, OverlapTest, CheckHeight, MovementSweepTest, ComputeGroundDistance, FindGround, etc), actually the same used internally by the system are exposed.

Those functions are there to help to implement custom custom game mechanics like, mantle, vault, ledge grab, etc. and should help in your case.

For example, to test 1m in forward direction from your current position you could use the MovementSweepTest, i.e:

bool blockingHit = _characterMovement.MovementSweepTest(characterPosition, transform.forward, 1, out CollisionResult hit);

The same to check if the target position is walkable you could use the ComputeGroundDistance or FindGround, the difference between this is the latter do a perch check while the former don’t.

All these functions let you test any arbitrary position just like if the character was moved.

Minor Update Released:

VERSION 1.0.2

  • Added Assembly Definition.

  • Minor bug fixes.

  • Fixed. CharacterMovement.detectCollisions not re-enabling collider.

Noticing a bug that kinda just randomly started happening, seemed fine before.
On Moving platforms the controller seems to “slip” the amount it sleeps seems to be tied to fps, the higher the fps the more it slips any ideas? It’s weird though, sometimes it’s completely fine, but if I click on a game object to inspect some components while the games running it might break again, but sometimes opening components up fixes it.
So something weird probably related to performance could be Editor related. I tried on 2019.4.0f1 and 2019.4.35f1 same issue

Mmm thats strange, however:

A cause for platforms slippery is due platform / character execution order. CM has been designed so the character is moved after the platforms have been updated, so he can read its current state. So if you are moving your character in Update, make sure you move your platforms in Update too, however when moving a platform in Update method, make sure you update its kinematic rigidbody position too or its collider will not be updated.

While character movement can work in Update without any issues (as long as you follow the above guidelines), my recommended workflow is using the LateFixedUpdate (as commented in docs) as this will give you seamless and rock-solid platforms and physics integrations without you having to do any special setup or write custom scripts.

Could you develop a bit about how you are implementing your platforms, I mean are you calling the Move function within your platform?

Im using the Moving platforms from your example scene specifically the Blue ones. I am updating in the Update function though.
All my code and whatnot from the original project was all inside Update() Im not sure what would be required port over to LateFixedUpdate() Since all our movement math and everything has been created and fine tuned inside the Update method.

Ah I see, yes the demo scene updates the platforms in its FixedUpdate and the Character in its LateFixedUpdate method, so both are updated in-sync in a frame rate independent interval.

In your case since you are using Update, you will need to update your platforms in its Update method but make sure those are updated before the character so both are updated using the same time.

I attached the modified platform example code, basically uses the Update instead of the FixedUpdate to move the platform and adds a default execution order so the platform is moved before the character.

Please take a look at the walkthrough guide from page 16 to 19 for a more in depth explanation of using update vs fixed update and how it affects game physics in general.

Last but not least, let me know if need any further assistance

Regards,
Krull

7890496–1004257–UpdatePlatform.cs (1.61 KB)

1 Like