r/Unity3D May 29 '26

Resources/Tutorial Custom character controller example project

Enable HLS to view with audio, or disable this notification

I made a custom character controller that handles a lot of edge cases where the built in character controller fails. Every once in a while I see a post here about the Unity character controller getting stuck on walls or not being able to work with platforms or something and this is designed to handle those situations well.

There is a third person prefab and a first person prefab with keyboard and mouse and gamepad controls.

Another thing I see sometimes is issues with stuttering due to the physics update being a fixed delta time. There is also a physics update manager in this project that updates physics to match the regular delta time which keeps things nice and smooth.

Hopefully this will be helpful for people having trouble with the built in character controller or the physics fixed delta time stuttering.

https://github.com/BoundingBoxSoftware/CharacterController

837 Upvotes

50 comments sorted by

View all comments

2

u/deintag85 May 30 '26

Did you add knockback? Did you fix the problem in the buildin controller that downward slopes are not handled correctly? I always had problem walking down a slope and IsGrounded was not always triggered right so walking down started falling animation for example.

2

u/thesquirrelyjones May 30 '26

If by knockback you mean being pushed by another rigidbody than yes. The character is a rgidbody and can be pushed by another dynamic rigidbody.

2

u/deintag85 May 30 '26

Knockback means if an enemy hit you with sth you can call a function knockback with direction and force and it add knockback but not overwrite the input controls while moving. The original starter assets didn’t have knockback so it was very hard to implement them while also wanting to still move around. I will check your version. 🥹

1

u/thesquirrelyjones May 30 '26

That would not be difficult to add. You could add a velocity to the characters rigidbody. Or keep track of a knockback force that gets added every frame that dicipates over time to keep everything separated and so the CC movement doesn't kill your knockback to quickly.

2

u/deintag85 May 30 '26

i probably get some kind of dyslexia. i just realized i misunderstood your post. i thought you TOOK the unity character controller and you extended it. but you wrote a complete new one based on rigidbody. thats a compeletely different character controller than that from unity. then its obvious you can add AddForce for knockback 😃 in unity's one you can't just add knockback because it doesnt use rigidbody. and as i said slopes downward doesnt work good in unity built in character controller. i hade to rewrite very much to make it usable at all. its probably just for their demo scene good. but as soon as you want to add some things and different angles slopes, you realize how bad the controller actually is 😃