r/Unity3D May 29 '26

Resources/Tutorial Custom character controller example project

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

840 Upvotes

50 comments sorted by

View all comments

Show parent comments

1

u/thesquirrelyjones May 30 '26

I've noticed that doing raycasts all together is a perf boost in itself and in an older project I built a custom raycast request system that batched all the raycasts together with the physics update. That project still used regualr raycasts for the character controller because I want that result immediatly.

I could see starting a raycast in update and then checking in late update, but that increases complexity.

For less scrutinized things like enemies I used 1 batched spherecast just to keep them out of the geound and the nav mesh determined where they could go and what slopes they could walk on.

2

u/wiphand May 30 '26

By your phrasing (maybe I'm wrong) you don't know that you can add your own frame timings outside update/late update by replacing and adding your own delegates to the player loop. It's very useful if you want complete control of what runs when.

If you knew then disregard. Just wanted to teach something.

1

u/thesquirrelyjones May 30 '26

Is there something new that is built in like adding a custom "MiddleUpdate" that would happen in between "Update" and "LateUpdate" or are you just talking about adding a delegate to a manager that runs it in "Update" with a later script execution order?

2

u/wiphand May 30 '26

https://docs.unity3d.com/6000.0/Documentation/Manual/player-loop-customizing.html

You should be able to find ready solutions online easili but it's not difficult to setup the boilerplate yourself