How crawling came to Minecraft
A deep dive into the development of an accidental feature
You may have noticed that you acquired a new skill last spring – the power of crawling! One would think that such a revolutionary skill was created with months of hard work and careful planning. Well, spoiler alert: it was all an accident! Care to learn how it came to be? Then grab a chair and hang on tight; this is the extensive behind-the-scenes story of how crawling crawled into Minecraft.
It all started with an innocent-looking bug report about hitboxes and eye heights. You see, all Minecraft mobs have a hitbox – an invisible box that represents how much space the mob occupies. If you play Minecraft on PC or Mac, you can see all the game's hitboxes by pressing the super-secret key combination F3+B (don’t tell anyone).
The reported bug was about incorrectly sized hitboxes or incorrectly placed eye heights, which was easily fixed thanks to our wonderful player community™ who helpfully listed all the errors that needed to be addressed. One interesting example that stood out was that the polar bear’s hitbox didn’t change during its attack animation. A polar bear stands up whenever it attacks, and if the hitbox doesn’t follow along, then the player can’t hit the polar bear on the torso when it is standing.
This hitbox error wasn’t confined to the polar bear, and we soon learned that even the player hitbox was wrong in its behavior. When you “sneak” by holding the shift key, your player model goes into a crouching pose. But the hitbox and eye height didn’t really follow along.
So how was this a problem? Well, the player eye height is also effectively the “camera” for your first-person perspective, so when you pressed shift to sneak, you wouldn’t really notice any difference because your viewing perspective wasn’t being lowered enough. This was an easy fix – just change one number in the Minecraft code and: tadaa, problem solved! Eye height was now in the correct position, and the player’s camera view would lower enough to make them feel like they are crouched.
This little problem was far from resolved though, as it turned out that the solution had an important side effect: By changing the player’s hitbox to a lower one, the player could now fit under a slab when sneaking!
Not only could you now crouch under said slab when sneaking – your head would also pop up above the slab whenever you’d stop crouching. The reason we got this result was because the game wasn’t designed for this, as it assumes a player is standing whenever they aren’t holding the shift key.
Letting players fit under previously inaccessible 1.5 block high space was actually a fairly significant gameplay change! What started as a seemingly small task was growing in scope, and a discussion was needed with the developer team to decide if this was a keeper or not.
After some discussion, we decided that this was something worth adding. However, coding it turned out to be quite a challenge, as the thing we call “sneak" literally had a whole 26 different meanings in Minecraft. This included things such as dimming your nametag, stopping you from sliding down a ladder, and dismounting you from a horse or minecart – and that's just naming a few!
All these things were lumped together and connected to the shift key, which made it really hard to work with. It also raised many questions such as; If you press shift to sneak under a slab, what exactly should happen when you release shift? If you are under a slab and not holding shift, should you move normally or slowly? Are you technically sneaking or not? What does sneaking even mean?
These questions, including the many different definitions, finally led us to the decision to eliminate "sneaking" as a concept in the code. It was a pretty big undertaking as a technical change and involved disentangling all the different behaviors from each other, to make it possible to configure each behavior separately.
There, that’s the story of how we learned how to crouch under slabs! Oh wait, this article was supposed to be about crawling? Fair enough, let’s continue…
From crouch to crawl
After fixing the crouching problem, we noticed a related issue that affected swimming. When you swim in Minecraft, your character is placed in a horizontal position, and as soon as you exit water, your pose switches back to vertical. But swimming into a one block high space now resulted in a visual glitch that made the character’s head stick up above a block.
Once we managed to fix this, the team decided to adopt a simple design principle: Whenever you don’t have space to stand, you crouch. Whenever you don’t have space to crouch, you crawl. Crawl animations don’t exist in Minecraft, which led to having us use the swimming animation for it. We did consider creating an actual crawl animation (even prototyped it), but decided that the existing swimming animation was good enough to continue using.
Now, as with all things Minecraft, any change to the code inevitably leads to unintended side effects. This particular change was no exception. The game was treating minecarts and boats as “not enough space to stand”, so the player would be forced into crawling whenever they tried to enter one.
Unintended side effects are not always bad though. For example, it also turned out players could use trap doors to force themselves into crawling – and use it to gain entry to small tunnels and secret passageways. This clever use of mechanics created new, interesting gameplay that could potentially result in a lot of fun scenarios. We really liked it, and eventually decided that crawling was a keeper.
The crawling mechanic is so far a Java-specific feature (it was accidental after all), and while we don't know when this feature could be introduced to Bedrock, we always work hard on improving the parity between our platforms. What we do know is that happy little accidents tend to happen, and are a part of what makes Minecraft the game it is today!
- Written By
- Henrik Kniberg