Back to Posts

The Legend of the Knee Grab

February 12, 2014, Bjørn Swenson

The Problem

After switching to Unity, we were up and running in no time with the canonical platformer physics model: A simple circle with a rectangle perched atop it. Things worked great — by keeping the physics body at a fixed angle, we were able to apply simple forces to get the character to move and jump. However, we ran into a small bug early on:

kneeGrab

Trella would get stuck on platforms, seemingly grabbing onto them with her knee. The only way to dislodge her was to drop down from the platform. Because we were early in the development process, we just flashed our “we’ll get to it later” card and continued hacking away.

The Great Depression

Before long, we had level designers scaffolding out prototypes of their levels and testing them in-game. We immediately got reports of the infamous “knee-grab” (you know a bug is bad when it gets its own name) rendering levels unplayable, and would happen nearly a third of time when attempting to grab onto a ledge. We finally decided to strap on our neckbeards and take a whack at the problem. Here is a zoomed in view of what we were up against:

kneeGrabCloseup

From this picture, we initially thought it was a problem with the circle or box getting caught on the corner of ledges. We tried tweaking the size of the circle and box collider in various combinations to fix things, to no avail. After consulting the Google gods, we determined that the box collider specifically was the source of our issue. We tried converting our player structure to use edge colliders and voila!

solution

Note

One disadvantage to this solution is that edge colliders can’t collide with other edge colliders. It turns out that putting a *small* box inside our edge collider worked beautifully:

endResult

2 Responses to “The Legend of the Knee Grab”

  1. Sophia Marie Baldonado says:

    The infamous knee grab.. I still have nightmares…

  2. Trella Fan says:

    She should just have hands coming out of her knees. Problem solved.

Leave a Reply to Trella Fan