A Simple Sonic-Like Character Controller

Rohan Naphade
2 min readMay 22, 2021

--

Like millions of others, I grew up with the classic Sonic Games and thoroughly enjoyed Sonic 3 especially. The 2d Sonic games stand out from your typical platformer because of their unique physics. This is also what the classic sonic in Sonic Forces, and Sonic Generations sorely lacked. This is what makes those games so good. Sonic accelerates with ease and goes up gravity-defying slopes. These physics can be recreated with a custom rigid body-based character controller. The unity rigid body has a lot of the functionality we need for a 2d Sonic controller but has some less than optimal features which prevent us from using it without running into some issues. Luckily, these issues can be solved quite easily. Let's start with the fields we need for the controller.

Now comes the locomotion of the player. This is done in Unity’s FixedUpdate() method.

Next, we must handle the main loop which deals with spin dashing and updating various variables

Awesome! All that is left is handling triggers such as those on springs and in water.

We are all done! You can easily add to this script by putting more triggers in here for enemies and rings and fine-tune the variables in the inspector. This is how your full script should look.

--

--

Rohan Naphade
Rohan Naphade

Written by Rohan Naphade

17 years old student developer

No responses yet