l89669

DEEP DIVES

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).
这一切的一切都源自于一个看上去无害的视觉bug,它有关于碰撞箱以及眼睛的高度。我们都知道,每个游戏中的生物都会有一个自己的碰撞箱,这个箱子是看不见的,它代表了你占据了多大的空间。如果你在电脑或者苹果电脑上玩我的世界的话,你可以通过按下超级秘密快捷键F3+B来查看碰撞箱,可别告诉别人哦。


The red line near the top is the eye height. It’s used to determine if two mobs can see each other. If they can gain eye contact, then they can target or follow each other.
顶部附近的那圈红线代表了眼睛的高度,它的作用是判断两个生物能否看见对方,如果他们的眼神能够交汇,那么他们就能锁定或跟随对方。


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.
这个bug的问题在于碰撞箱大小不正确,视线的高度也不正确。非常感谢我们的玩家合作伙伴™帮我们找出了需要被解决的错误。举个有趣的例子,北极熊在攻击的时候,碰撞箱并没有随着动画而改变。北极熊攻击的时候会站起来,如果碰撞箱没跟上动画的话,玩家就不能打中北极熊站立时的身体。

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.

这种碰撞箱问题并不仅仅发生在北极熊身上。我们很快就找到这种错误也发生在玩家身上。当你按住shift潜行的时候,你的模型显示你是蹲下的,但是碰撞箱和视线高度还是原来的。


Polar bear attack before the fix.
修复前的北极熊攻击。





Polar bear attack after the fix.
修复后的北极熊攻击。





Hey red eye height line! You were supposed to follow the player’s head when sneaking! Good thing we fixed this.
喂,红色框框!你应该跟上蹲下的玩家才对!还好我们已经修了。


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.
那么,这样的问题是怎样的呢?玩家的视线高度其实也对你的第一人称视角相机高度起效,所以当你潜行的时候,你并没有什么感觉,因为你的视野没变低。这问题修复起来还蛮简单的,只需要修改一下代码中的一个数字,然后,江江!问题就解决了!现在眼睛的高度就很正确了,然后视野也会跟着降低,足以使玩家觉得他蹲下了。


Crouching after the eye height change, which made it much more visual compared to the old subtle one.
视野下蹲时的变化,这样比以前更加的直观了。


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.

不仅你现在可以蹲在台阶的下面,你还可以把头穿进去,只要你松开潜行键。之所以这样,是因为游戏并没有设计这种情况的应对方式,而玩家只要松开shift键,他就会站直。

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.

让玩家能够进入以前无法进入的1.5方块高的空间实际上是一个非常重大的游戏性变化!在一开始这仅仅是一个小事,现在却需要整个开发团队开会讨论是否保留这个特性。


So this is what happens when crouching under a slab and then let go of the shift key? The head sticks up right through the slab (well visually at least)! Ouch!
所以这就是当玩家潜行进入了台阶下方,松开潜行键后会发生的事情。玩家的头穿模进入了台阶(视觉上)。好痛!


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!
在一番讨论之后,我们认为这确实很适合加入游戏。但是实际证明,想要在代码层面实现它是一个非常大的挑战。因为我们用“sneak”表示的东西在游戏里有整整26种不同的。这其中有黯淡你的玩家名标签,阻止你在梯子上下滑,还有从载具上下来——这还只是一小部分。

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?
这些东西都集中起来映射到shift键上,这导致我们很难推进工作进度。由此而生的也有很多问题,比如:如果你潜行进入台阶下面,当你松开潜行的时候会发生什么事?如果你在台阶下方又没有按着shift键,你应该是正常移动还是缓慢移动?技术上你现在是否在潜行呢?潜行的本质又是什么呢?

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.
在修复了蹲的问题之后,我们意识到了有一个和游泳有关的相关问题。当你在游戏中游泳的时候,你的人物其实是横着的。一旦你离开了水,你的人物又会重新站起来,但是现在游进一个一格区域会导致一个视觉上的错误,人物的头会穿模进入上一层方块。


Darn! The head-sticking-out-through-block problem again! It was only a visual glitch, but still needed to be fixed!
见鬼!头又穿模进入方块了!这只是视觉上的问题,但是还是得修啊!





The solution was to let the character in the swimming position, even after leaving the water. Silly, yes, but better than having your head stick out through the ceiling!
解决办法是让角色在这种情况下保持游泳的姿势。虽然看上去很蠢,但是至少好过穿模吧?


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.
不过,意外也不仅仅是坏事。比如玩家可以活板门使得自己进入爬行状态,而且可以借此进入一些小通道或者密道。这样的机制可以给人新鲜而有趣的游戏体验,我们很喜欢这个特性,并决定保留爬行特性。


With the addition of crawling, we even considered adding a dedicated hotkey for it, but decided not to. Crawling should require some creativity from the player!
因为添加了爬行,我们也考虑过给它加一个专门的快捷键,但是最后还是放弃了,因为爬行只属于有创造力的玩家!





Crawling allows you to do all sorts of silly things – like hiding in a composter.
爬行可以让你做些傻事——比如躲在堆肥桶里。





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!
就目前为止,爬行也只是JAVA版本独享的特性,毕竟这是偶然诞生的。虽然我们不知道这个特性什么时候能被引入基岩版,但我们一直致力于互通平台间的一致性。我们所确信的是,这些时常发生的小意外,也塑造了我的世界如今的样子。

【华华苦力怕 译自官网 2020 年 07 月 21 日发布的 How crawling came to Minecraft;原作者 Henrik Kniberg】
【本文排版借助了:SPX

卡狗
标题好喜感……😂我这就爬(

whatfilmae
我就很喜欢爬,我玩游戏天天爬

xiaoqi123123
代入感太强,我已经开始爬了!

七七八
        MCBBS有你更精彩~

金牌猎马人
艹,感觉莫名被冒犯,游戏里已经在爬了

黒猫の橙
我记得,是一个企图通过推动方块让我窒息的活塞

ctr123
我一般爬都是游完泳后钻进一个小洞