I want to create a small 3d platformer, Mario-64 style, but I’m not sure of what to use for the actual player movement. I don’t want anything fancy, just being able to jump and run through the level made of meshes (with slopes), without worries of falling through stuff, or getting stuck anywhere.
My question is: for non-realistic character movement (again, something like Mario 64) should I use the existing Character Controller? I’ve read that it’s subpar and I might have problems in the long run.
I tried the excellent-looking SuperCharacterController from Roystan Ross (of Super Mario 64 HD “remake” fame), but unfortunately it seems to have problems even on the sample scenes (falling through the scenery and getting stuck on edges).
I’ve also read that Unity 5.6 includes two new Physics functions that might help when creating a Character Controller (Physics.ComputePenetration and Physics.ClosestPoint). Should I go and create my own instead using those two new functions?
I guess I should also ask if there is something on the asset store for this, but from what I’ve seen, there is a lot of cruft out there, so it might be difficult to find the right thing without a way to test it beforehand.
Anyway, sorry for the not-so-focused topic, and hopefully somebody can provide some insights at least :).
I can only say that I have seen so much problems trying to make the physics system do what you want in Unity, so writing a good character controller which doesn’t get stuck etc. doesn’t seem as easy as one’d think so you’ll probably end up having to tweak your physics interactions until they’re “good enough”.
But perhaps someone who has actually made a 3D platformer could give some insight.
Hey arcnor, the way Super Mario 64 handles this (but not the Mario 64 HD project) is that the world is strictly divided into walls and ground. All surfaces in the world have to be one or the other—you’ll notice this is why Mario is able to stand on some fairly steep slopes in the game (such as the big ramps in Bowser in the Sky). Dividing the world like this makes it much easier to do ground detection and makes your controller more stable overall.
The 5.6 Physics functions are pretty great overall and are very useful for writing custom character controllers, but are not absolutely necessary if you want to make a solid controller in Unity. While the CharacterController has its issues, it’s a good place to start and lets you immediately start working on the actual interactions of the controller, as opposed to writing somewhat lower level code.
On the subject of the SuperCharacterController, the main reason it gets “stuck” and whatnot is due to the technique I used to detect ground beneath the character, which wasn’t very stable and would frequently either “miss” when you’re up close against walls or oscillate between a grounded and non grounded state. These days I use a much simpler technique that uses a custom SphereCast function to detect all triangles beneath the controller and pick those that are most relevant.
@Iron-Warrior I want first to say thank you for your very informative articles, and of course for the SCC itself.
Do you have any articles you can refer me to, to learn about that new simplified technique you’re using?
I’ve applied the SCC (using the example PlayerMachine) to my project, and it sort of works (besides the aforementioned problems), although for some reason the gravity seems to be messed up (jumping shots my character into the air), but I’m still debugging why.
Anyway, I’ll keep to the original CC or the SCC for my project, thank you again.