I have an issue with my character controller, when I jump, it sometimes lands on surfaces it shouldn't be able to land on, like very steep slopes etc (even though my max slope is 45 deg). In this case, Controller.isGrounded() still is true. The controller doesn't fall off the steep slopes either, it just stays there and the controller can jump again.

I also notice that the controller sometimes can climb heights very awkardly (after jumping), like it is barely touching the elevated ground surface yet it can "push move" to climb it's way up

These problems both occur in the standard implementation given by unity https://docs.unity3d.com/ScriptReference/CharacterController.Move.html

See also: https://i.imgur.com/AD6dVy2.png (here it can jump on the steep slope and stay there, UCC is the example script from unity copy pasted)

How can I fix these things? Are there any existing solutions or guides for better character controllers?

  • \$\begingroup\$ What would you like to happen instead in these situations? \$\endgroup\$ – DMGregory Jun 10 '20 at 21:35
  • \$\begingroup\$ @DMGregory So I am updating my downwards velocity with gravity, but it doesn't seem to actually make me slide off very steep surfaces and also counts as IsGrounded(), which is one big issue. The other big issue is the charactercontroller being stuck on the sides when I jump onto a platform I can barely reach (the butt of the capsule collider isn't fully on the new platform, yet it can move up) \$\endgroup\$ – xcrypt Jun 11 '20 at 0:19
  • 1
    \$\begingroup\$ Sounds like you should show your code in your question so you don't have to describe it in a comment. \$\endgroup\$ – DMGregory Jun 11 '20 at 0:26
  • \$\begingroup\$ @DMGregory Well I'm using the standard implementation from Unity documentation slihgtly modified, but both run into the same issues I described. See docs.unity3d.com/ScriptReference/CharacterController.Move.html \$\endgroup\$ – xcrypt Jun 11 '20 at 10:49
  • \$\begingroup\$ Sounds like you should show the actual modified code you're using inside your question itself. \$\endgroup\$ – DMGregory Jun 11 '20 at 11:07

enter image description here

So here is my thought on the issue, there may be an easier way but that doesn’t matter you have to start somewhere.

I’m assuming you are using a ray cast in order to check if the player is close to the ground, so what you can do is use RaycastHit.normal() to get a new vector that represents the normal of the object.

With this new vector you can calculate the slope of the plane, if it is steep enough you want to add a small force to the players horizontal.

That should be it, if you have anymore questions or you need clarification on anything I said (which you probably will seeing how I’m not wonderful at explaining things) please contact me.

  • \$\begingroup\$ Just to add, it's probably better to use sphere cast, because ray casts are prone to "quantum" effects, e.g. small hole in the ground would put character in airborne state. \$\endgroup\$ – Shadows In Rain Jun 12 '20 at 8:16
  • \$\begingroup\$ Hm I see. That looks like something that could work. I'm not doing any raycasts though, I'm just using standard charactercontroller unity scripts which does a lot of things by itself. I don't know whether I can access this underlying code, charactercontroller works quite different than a dynamic rigidbody+collider. \$\endgroup\$ – xcrypt Jun 12 '20 at 14:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.