Creating a Physics Based Character Controller in Unity

Character Controllers boost the player mechanics!

If we want our player to move in a world space then a Character Controller is what we should use to create the player actions.

Common Usage

Character Controllers can be used anywhere, you as a programmer can decide how to implement one in your project.

But there are moments where it should always be used like in FPS games and Third Person games.

Assasins Creed Unity’s Character Controller with Parkour Features

In my opinion, Ubisoft’s Assasins Creed Series has one of the best character controllers I’ve ever seen. The camera is very well made with an adjusted smooth movement, the parkour mechanics never get bugs and the gameplay mechanics is just perfect. It makes you feel like you’re there, running through Paris streets doing all those crazy parkour movements!!!

Let’s create a simple character controller inside Unity

In this example we’are going to be creating a Third Character controller combined with cinemachine to create a the player’s movement and camera follow.

Defining the class fields

Don’t be scared, if you see to much code there. What it basically define, are the parameters to make our character move correctly through the world. We need to specify the floor layer so the player knows where he/she is allowed to walk.

Let’s define our Move method

With these lines of code our character will move perfectly. We’re implementing a movement based on where’s the camera looking at.

We also check if the player is grounded to let him jump.

Controlling when it’s ground

Let’s just give a little and simple explanation for this. We are creating a sphere raycast to detect if there’s some floor behind the player and make it “grounded”.

Setting up our Cinemachine camera for camera follow

I’m gonna leave this brackeys(Unity Legend) tutorial on how to set-up the camera to work in our game!

Final Result

In this sample scene I used HAON’S Unity Chan model to use the CharacterController on the player.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store