Skip to content

AstroCappy's Character Controller

Ensuring the input has the best feeling.

Cappy's AI rendition

AstroCappy's rendition with generative AI. None of these are how the actual game will look like, although a pixel art style like the one on the left is what I'm aiming for.

This update took a long time to make

For this post I had to figure out solutions to including the WebGL game build in the page. This involves things like trying new node dependencies, CSP changes and more just to get a "playable version" to show. I also had to look at embedding YouTube videos properly.

What is a Character Controller

A character controllers is a system that handles the player's input and translates it into character actions, like moving and jumping.

Why is it important to get the movement right?

Mark from GameMaker's Toolkit explains it really well in this video: Why Does Celeste Feel So Good to Play?

Reacting to player input

We want to check for the player's input as often as possible, while at the same time keeping the physics simulation at a fixed rate, to ensure a consistent experience across different frames per second.

For this we set our input checks inside the Update methods and our physics inside the FixedUpdate methods of our scripts.

Following the tutorial series

Adding and configuring a character controller is one of the first things done in a game. Thankfully there are many tutorials and guides on how to do this.

I started following the series from Shinjingi called The ULTIMATE 2D Character CONTROLLER in UNITY. This was recommended by GMTK when Mark was developing his own game.

Unfortunately this guide does not use Unity's new input system. It's made with the old input system. And because I want to use the new one (to allow for easy remapping and multiple input devices), I've also had to look for a tutorial about using the new input system. I found one here: How to Use Unity's New Input System with Scriptable Objects

I used what I learnt from both tutorials to create my own character controller.


Shinjingi's last video on the series is about the new input system. I realised too late.

AstroCappy's movement

Our protagonist Cappy, will be able to move left and right, jump, double-jump, slowly slide down walls, wall jump, and dash.

These are all very common mechanics in platformers.

I personally like the feeling of Hollow Knight's or Celeste's controller.

Note that I left out combat (shooting in Cappy's case), as I will be firstly focusing on movement.

All these actions are covered in the mentioned tutorial series. With no art being made yet, we will be using a red rectangle as our placeholder character.

The tuned values for speed, acceleration, gravity, max height, etc. might very well change once the game starts taking shape. For now I believe I chose some reasonable starting values by looking at existing games.

These are some of the behaviours I decided after studying different characters:

Assuming Cappy is 1 unit wide and 2 units tall.

Movement SpeedCappy should be able to get to around 8 units per second with almost instant acceleration
Jump HeightCappy should be able to jump around 3.5 cappys high (7 units) but can jump lower if letting go of the jump button
Airjump HeightAssuming cappy has the double jump unlocked, jumping in the air can only add up to 2.5 cappys (5 units) of height
Wall SlideCappy should slide down walls (if unlocked) at a speed of 3 unit per second
Wall JumpCappy should jump from a wall (if unlocked) up to around 5 units to the side and 8 units high
DashCappy should dash (if unlocked) in around 200ms with great speed, and with a cooldown of 1.5 seconds

Unfortunately, many of the variables that need to be changed to achieve this are forces like gravity or acceleration given. This meant the fine-tuning was very manual and results are approximate. If things didn't feel right, I would change the values and try again.


Using Unity's new input system manager, it's easy to create an input action map, where named actions are bound to certain keys. It allows easy binding of gamepads as well, for example. For touchscreen input you can use the builtin OnScreenStick and OnScreenButton to trigger gamepad keys for example.

To test everything I made a very simple scene with walls and platforms.

Try it out

A "playable" version can be found below. See if you can get to the top of the level.


Keyboard: Use the arrow keys to move, 'Z' to jump and 'C' to dash. It also supports gamepads and there's a joystick and buttons for touch input devices.

Last updated: