Skip to content

Custom 2D platformer character controller for Unity

License

Notifications You must be signed in to change notification settings

vrompasa/2d-platformer-character-controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

2D Platformer Character Controller for Unity

Provides more precise and snappier controls for a platformer game than the default Unity character controller.

The repository contains all required assets for a demo scene to demonstrate the controller. The important files are in the Assets/Scripts/ folder.

Features

  • Raycast based collision detection
  • Wall jumping and wall sliding
  • Support for one-way platforms with the ability to drop through
  • Reactive jump: Jump input is still recognized right before and after being grounded or after touching a wall
  • Ability to control jump height by releasing the jump button mid jump

Not supported:

  • Slopes
  • Moving platforms

Setting up

  1. Add the MovementController.cs and Player.cs scripts to your player game object.
  2. Make sure the player has a Box Collider 2D attached to it.
  3. Set up the collision masks inside the inspector.
  4. Start tweaking the parameters!

One-way platforms:

  1. Attach Edge Collider 2D to the platform game object.
  2. Tag the platform as Platform.

Pressing "Down" on a platform will make the player fall through it.

Resources:

Languages