[Released] Kinematic Character Controller

Kinematic Character Controller a relatively low-level character controller solution that is not tied to any specific game genre and is made to be cleanly integrated into any project/architecture with as little friction or bloat as possible. Instead of using rigidbody physics, it uses a “collide and slide” algorithm that makes its movements perfectly fluid, precise and responsive. Note that its “kinematic” nature means that interactions with rigidbodies must be explicitly scripted, and that they won’t happen automatically.

Asset store page
WebGL Demo
Release Notes
Upgrade Guide

Here is a showcase of the example character included in this package:

Feel free to ask questions here if you have any.

enjoy!

14 Likes

Looks pretty impressive, those steps and rotating platforms look super smooth. Nice job.

Any idea how it performs compared to the unity built-in character controller?

I haven’t compared, because it is not really a direct comparison. Despite being relatively “low-level” compared to most of the other CC’s available on the store, this character controller still is more high-level than Unity’s CC. (due to things like moving platform handling, etc…)

However, I did make a stress test where I had 800 of these characters running at 60 fps on my machine (I have a 3 year old mid-high range Core i5). A single character’s update takes about 0.07 ms in a build

2 Likes

Very impressive footage. I’ve been battling with this crap for ages (well, you already know), but it looks like you beat me to it!

Looks nice. How about some kind of playable demo?

I will see about releasing a WebGL build shortly. Stay tuned

Lel.

Really nice controller this one, I’m definitely scrapping mine, it’s utter shit in comparison. :C

3 Likes

Haha… oops. I’ll see if I can make a more elegant “uncrouching” logic (there is none at the moment)

nice find

4 Likes

Haha, apart from crouching the main feature that imo could be generic enough to warrant investigating would be ‘forced motion’, things like Genji dashes in Overwatch, or perhaps crouch-slides in games like Far Cry 3/4 or Dishonored. In these situations you want different logic for movement (straight forward in view direction for Genji, or low friction and perhaps faster down slopes for sliding), but still need robust collision checking. It might not be suitable for you to implement, but some direction on achieving things like that would probably be helpful!

As for uncrouching logic, I think all that is needed is to check if there is space to stand, and remain crouched if not.

A configurable feet size(if it doesn’t already exist?) would be nice, so you can configure how far out on an edge you can stand before gravity kicks in.

The way things work when you wish to create you own character controller with this system is that you create a class that inherits from ‘BaseCharacterController’, and you simply implement all abstract methods. For example; there is an UdateVelocity() method in which you must simply return the velocity you want your character to have right now

To implement something like ‘forced motion’, all you would have to do is that if you’re in a standard movement state, you return what the ExampleCharacterController is returning right now… but if you’re in a ‘dash’ state, you’d return a constant vector that corresponds to the original dash velocity for as long as the dash persists.

I will most likely expand the ExampleCharacterController with several movement examples (like dashes, swimming or double jumps) in order to give you guys a better idea of how all this could be done. This would come in a later update

yup, will do that in the next update

Good news; this setting already exists! It’s in KinematicCharacterMotor, and it’s called “MaxGroundedDistanceFromLedge”

In other words: “what is the maximum distance between your center and the ledge at which you can still be considered stable on the ground”

Let me summarize all of the initial feedback I’ve gathered so far in here and from owners:

  • There should be a browser demo
  • There should be more examples for things like rootMotion, swimming, dashing, etc…
  • There should be a way to activate/deactivate the character physics completely
  • Uncrouching should be handled better
  • Documentation should more clearly explain how to make a character controller from scratch (with a real example)

I’ll be working on an update that solves all of this over the next few days

1 Like

Hey PhilSA, I’ve done some initial playing around with the Kinematic Character Controller and here are a couple things I’ve noticed:

  • You can’t jump while sliding. It looks like the jumping code is checking if the controller is grounded in order to jump. I haven’t looked yet but I assume that sliding is handled as if the character is no longer grounded, which means you’d have to dig into the character motor to fix this. I think ideally we need some way of differentiating between being in the sliding state and the not-grounded state. This would also be useful for triggering animations for sliding as you could simply check “KinematicCharacterMotor.IsSliding” (as an example).
  • The second thing I found is the only real bug I’ve run into so far. It’s best described by this gif, but essentially the character controller will not be able to step up steps while the planet is in a certain rotation.

PartyBoat: I don’t think this is meant as a generic sliding mechanic. It’s more like a way to separate walls from ground. The controller should give you enough environmental information to implement your own sliding mechanic with ease, that you can tune to your liking.

@PartyBoat is right about the fact that if you wish to know if you’re standing on something even though you’re not “grounded”, you have no other option than to modify KinematicCharacterMotor. Ideally, KinematicCharacterMotor is the big complex thing that 99% of users shouldn’t ever have to touch, so I’ll definitely add something to fix this. Right now I’m thinking it could store some kind of “GroundProbingHit”, which would be the entire RaycastHit that the ground probing phase detected, whether it was grounded or not. From this you could access the collider, the normal, etc…

I’ll look into the planet stairs bug too

EDIT: I added my current task list at the bottom of my first post, so you guys know what I’m working on. I’ll keep this updated at all times

EDIT2: Just solved the stairs problem on the planet. It actually revealed a pretty big flaw in my ground detection code whenever the character wasn’t completely upright. Big thanks for bringing this to my attention. The fix will be part of the next update

1 Like

Update: Added a WebGL demo! (Firefox is highly recommended)

It definitely feels smooth, and it works great on Unity Terrains?

It does work just as good on unity terrain too. I’ll update the browser demo with a small terrain example later today

(I left out the big terrain you see in the video because it was too rendering-heavy for WebGL and it affected framerate a bit too much)

EDIT: Browser demo has been updated with terrain

1 Like