Battle Guys

 

Overview

Battle Guys is a 2D platformer demo that features a 2D character controller with custom physics and platforming abilities.  The physics and abilities of Battle Guys are inspired by the unique physics found in games such as Sonic the Hedgehog and Super Meat Boy.  Some of these features include a robust wall-running system, variable jumping, air flips, acceleration/deceleration, and more.

This project was originally supposed to be a local multiplayer brawler.  After multiple design changes, I decided to just focus on refining the character controller and movement.  I have some ideas for different directions to take it, so I would like to revisit this project in the future.


Character Controller

Battle Guys uses raycasting to detect collisions with flat, sloped, and curved surfaces.  The result is a pixel perfect 2D character controller.  If the character has a rigidbody component attached, then that will be used for movement.

The character's current velocity changes both the length of each ray, and which side of the character it casts from.  Rays are cast on the same sides as the forward moving directions.  So if the character is moving left while jumping upward, then rays will be cast from the top and left sides of the character.

The character controller also handles descending and climbing slopes.  A maximum angle can be defined to prevent climbing and descending slopes that are too steep.  Slopes that are too steep are treated by the controller as walls.  The character adjusts itself to be perpendicular with whatever surface it stands on.

 

Wall Running 

When a character hits a wall, there are two possible outcomes: they stop dead in their tracks, or they start running up the wall.  Two conditions must be met in order to run up the wall.

  • The difference between the wall's angle and the angle of the surface underneath the player is less than 'X' degrees.
  • The current speed of the character is high enough.
 

Flips and landing

While in the air, players have  control over the rotation of their character.  The momentum from the flip and character's current velocity will cause it to continue flipping without player input.

As a way to auto correct the landing angle after doing a flip, the character will do a flip recovery upon landing. This consists of a small bounce and a quick flip to adjust to the surface's angle.

 

No Flip Input

With Flip Input