Tech: Operation DE-JANKify


Movement jank

A major goal of our first patch is to remove jank in T-SOL. It looks ugly and makes the game frustrating to control. A big source of jank is in how we handle collisions with the scenery. We are using a system that we originally created way back in 2015 for our first Toronto Game Jam project. It worked well there and in a later TOJam project in 2017 but those games had large, thick, platforms with rectangular colliders. T-SOL, on the other hand has much thinner platforms in places. That leads to jank like this

The old collision system uses what is called raycasting to detect collisions. The player character, Saul, sends out a line, called a ray, to find the nearest wall. If the ray hits something close enough then Saul is about to touch it and needs to be stopped. If the thing being hit is closer still we know Saul is inside it and needs to be pushed away a little. It's simple and extremely easy to control. We use two rays, one toward the top of Saul, and one at the bottom. The problem is that the platforms that cause jank are short enough to sneak between the rays.


When this happens the platform eventually gets far enough inside of Saul to trigger the rays used to detect the floor or ceiling. Saul abruptly teleports to be standing on the platform. In the worst case Saul can be pushed back leading to a cycle of going in and out of the platform while falling then teleporting upward. The result is some nasty jitter on the edge of platforms.

The fix for this is to handle walls using a box instead of rays. Like this

  1. Check for all map colliders inside the box
  2. If any are there find the nearest point on them from the center of the player
  3. Find how far inside the player's hitbox the point is
  4. Move the player that amount so they're outside of the collider

The new behavior, with fancy debugging graphics, looks like this. No more jitter.


But that's only half the jank. What about the camera?

The camera is relatively complex. Since the game involves making some long jumps it's necessary to have it look ahead of the player. If we don't then a lot of fairly easy jumps become frustrating blind jumps. In addition we don't want the camera to look through the map into areas that aren't relevant for play. Having half the screen taken up by ground isn't a good look.

The biggest thing that makes the camera feel bad, to us, is how it wildly swings around when the player adjusts a jump in midair. A big part of this is that the camera responds immediately to the player changing direction. If you wiggle around quickly the camera does so as well.

In order to fix the wiggle the camera needs some limit on when it's allowed to change direction. There are two general solutions. One is having a "dead zone" where moving within it does not make the camera move. The other would be to time limit camera look-ahead changes. Either could work but finding what will work best requires testing.

The final source of jank is the camera's view area getting hung up on scroll stops. At the time of writing the solution for this has not been determined.

Get T-SOL - Early Access Demo

Leave a comment

Log in with itch.io to leave a comment.