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.
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
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
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