This week I spent most of my time doing the following:
Tutorial Makes Perfect
I've always been a little unsatisfied with the gravity and physics in Unity. Unity used to be specialized in semi-realistic 3D games, so the physics match what you would expect from reality. However, it always caused platformer games to feel floaty and slow. I wanted to write my own 2D character controller, so I could tweak as many aspects of it as possible and make the game's jumping feel fast and fun.
Luckily for me, Unity itself provides a set of tutorials about how to create your own 2D physics and character control. With those, I was able to create my own, with tweakable settings.
Rigidbody and Capsule Collider are (obviously) default Unity components. Player Control lets the player control their character. The script inherits from a C# class I had to write that handles gravity and collision, since we're not using the default gravity created by a Rigidbody. I put in a few settings to modify to make it easy to find a satisfying walk speed and jump speed.
While I was at it, I took a sound effect sample to play when the player jumped. I wanted to manage the audioclips in a different script, but making it a separate setting in the same script was a lot simpler.
The default Unity camera also leaves a lot to be desired. It can effectively follow a character, but it doesn't work the way you would want to. I initially wanted to write my own camera system, but I found out about Cinemachine, a free plugin that creates highly tweakable cameras.
With Cinemachine, I was able to create a "deadzone": an area where the player can move their character freely, without the camera moving along with them. This is common for 2D platformers. On top of that, I was able to add a "confiner". The Cinemachine confiner requires a polygon collider, and the camera will not be able to move beyond that area, so the player can't see outside of the level.
I ended up finishing a bit early in the week, so I filled up the time working on:
Next week: More platforming mechanics beyond the basic jump.