Create a Physics based Character Controller in Unity
You can create a custom character controller using any of Unity’s built in primative shapes. In this example, we will be using a capsule.
After adding the capsule, the first thing you’ll want to do is remove the “Capsule Collider”:
With the player object selected, add the “Character Controller” component:
Next up, we need some platforms for our player. Let’s use some cubes to set up a few platforms:
With our player and platforms ready, it’s time for some scripting. Create a new script called “Player” and add it to the Player object in the scene.
After opening the script, the first thing we need to do is to move the player. We can do that by accessing the character controller component:
The code above allows us to move our object to the left and to the right with a speed multiplier of 5. If we want the ability to jump, we can simply implement our own gravity variable. We can also ignore gravity with the Character Controller’s built in method “isGrounded”. Let’s put it together and organize our code with a “Movement()” method:
This is fine for a perfectly symmetrical object, but what about something with a face? There are numerous ways to accomplish this. One way is to use Mathf.Sign which returns a plus or minus sign and pass in the horizontal input as an argument:
The final product should look similar to this: