Essays北极甜虾 · No. 26

玩物有理 · 第三篇

DOTA2 的 Z 轴,
到底管什么用?

一个假装三维的平面游戏
在 DOTA2 里,敌人被冲上了天,地上的技能照样能打中他。这不是 bug,因为在游戏的账本里,他根本没离开过地面。这篇聊聊 DOTA2 里的高度,也就是 Z 轴:它管什么,不管什么,以及为什么要这么设计。
你看到的:屠夫被冲上了天昆卡屠夫司夜刺客游戏记下的:屠夫还在地上
图 1同一个瞬间的两种样子。上面是你在屏幕上看到的:昆卡的洪流把屠夫冲上半空,司夜刺客的穿刺从地上扎过来。下面是游戏记下的:每个英雄只是地上的一个圆,屠夫的圆一点没动,穿刺扫过的那一条照样盖住了他。卡通英雄是本文自绘的 Q 版示意,不是游戏里的官方形象。

打过 DOTA2 的人大概见过这一幕:昆卡一个洪流,把敌人冲上了天。人还在半空,地上的范围技能砸过来,他照样被打中。

玩家社区的维基专门拿这个当例子:被洪流冲起来的单位,还在空中时,照样会被司夜刺客(小强)的穿刺完整地打中。

按常理说,人都飞起来了,地上的东西怎么还碰得到他?答案藏在游戏的底层:DOTA2 看上去是一个三维游戏,可它的大部分规则,是在一张平面地图上算的。高度,也就是三维坐标里的 Z 轴,只在少数几件事上说了算。

这是“玩物有理”系列的第三篇,每篇拆一款游戏背后的道理。这一篇想讲清楚:DOTA2 的 Z 轴,到底管什么,不管什么。

账本上只有平面

先看游戏怎么记一个英雄在哪。

DOTA2 的地图被切成一张大棋盘,每一格是 64 × 64 个游戏单位见方。英雄能不能走到某个地方,是在这张棋盘上算的:哪些格子能走,哪些格子被树、悬崖或者建筑挡住了。这张棋盘只有一层,只记“这一格能不能走”,不记“第几层能不能走”。

英雄自己的“身体”,在规则里是地面上的一个圆。按社区维基整理的数值,普通英雄的碰撞半径是 27 个单位:两个英雄最近能挨到的距离,就是两个圆的半径加起来。攻击距离、施法距离,也都在平面上量。

至于英雄的脚离地面有多高,大部分时候根本不用记:它站在哪,脚底下的地面有多高,它就有多高。社区维基特别提到,就算是会飞的单位,它的模型飞起来了,碰撞用的那个圆还是留在地面上。

地形是一层一层垒的

那高低起伏的地形呢?也很简单:它是一层一层垒出来的台阶。

河道兵线河道高地0128256地形一层一层地垒起来,每层高 128(游戏里的长度单位)
图 2地形的剖面,示意:河道里插着一只眼,昆卡站在兵线上,卓尔站在高地上。按 Valve 2014 年写给自定义地图作者的文档,可走的地面按 128 个单位一层来搭,河道在 0,中路在 128。

Valve 在 2014 年写给自定义地图作者的文档里说,地图上能走的地面,要按 128 个单位一层来搭;河道在最底下,高度是 0,中路在 128;战争迷雾最多只分 32 个高度层。现在的正式地图,按社区维基的划分,真正影响玩法的大约有六层:河道、低地、高地,再往上是泉水那样更高的台子,等等。层和层之间,靠斜坡相连。

这样搭出来的地形,有一个很好玩的性质。

为什么没有立交桥

中学数学里有一个“竖线判别法”:一条曲线是不是某个函数的图像,就拿竖线去试,每一条竖线最多只碰到它一次,它就是。

高度图:可以每条竖线只碰到地面一次桥:做不到这条竖线碰到两层:桥面和桥下
图 3竖线判别法。左边的山坡,每条竖线只碰到地面一次;右边的桥,同一条竖线碰到了桥面和桥下两层。示意。
道理一层的地图,造不出立交桥

如果地图上每一个平面位置只记一个地面高度,那就不可能有“桥上能走、桥下也能走”的地方。

理由桥上的人和桥下的人,站在同一个平面位置上,脚下却是两个不同的高度。可地图在这个位置只记了一个高度,装不下第二个。这和竖线判别法是一回事:在这个位置竖一条线,它碰到了两层地面,所以这张地图就不是“一个位置一个高度”的样子了。∎

DOTA2 的寻路棋盘正是这样:一层,一格一个“能不能走”。所以在规则上,它很难做出立交桥、地道、楼上楼下这种东西。2025 年底的 7.40 版本在地图上换上了几座桥的模型,但我没查到单位能从桥底下走过去的说法。你去回想一下 DOTA2 的地图,大概也想不起哪里有“上面一条路、下面又一条路”的地方。

高度管的第一件事:视野

既然大部分规则都在平面上算,高度到底管什么?最重要的一件,是视野。

规则说起来很简单:站在低处,看不见比自己高的地方;站在高处,下面基本看得清。树会挡住同一层的视野,也会挡住高一层的视野。会飞的单位有“飞行视野”,地形和树都挡不住它。

我照着这几条规则,画了一张简化的小地图,在三个地方各插一只同样的眼,让程序算它们各看得见多少格。

眼在河道:看见 38 格眼在兵线:看见 100 格眼在高地边上:看见 100 格黄:看得见。浅蓝是河道,浅灰是兵线,深灰是高地;绿点是树
图 4同一只眼插在三个地方。插在河道里,被两边的坡挡住,只看得见河道本身;插在兵线或者高地边上,能看到一大片。地图和规则都是本文简化的,格数由本文程序算出。

同一只眼,插在河道里只看得见 38 格,插在兵线上能看见 100 格。这就是为什么高手都爱把眼插在高处:位置高一层,看到的东西能多出一倍还不止。

第二件事:低打高会丢

高度管的第二件事,是攻击。

远程攻击从低处打高处,有 25% 的概率丢失,打空。这条规则至今还在,而且和你有没有对方的视野无关;近战不受影响。2017 年的 7.06 版本起,飞行单位不吃这个惩罚;2019 年的 7.22e 版本起,它改成了“伪随机”,不会连着丢太多下。

这条规则比 DOTA 本身还老。DOTA 最早是《魔兽争霸 III》里的一张自定义地图,而暴雪官方的《魔兽争霸 III》攻略里就写着:远程单位从低处往高处打,有 25% 的概率打不中。

第三件事:被抬到空中

回到开头那一幕。洪流、小小的投掷、各种旋风,都会把单位抬到空中,这时候它的 Z 轴确实变了。变了以后,会影响三件事。

投射物追着身体中心飞飞得越高越晚到阻挡高度差得多就互不挡路范围技能空中地上昆屠不看高度照样打中
图 5单位被抬到空中以后,高度管的和不管的。左:卓尔的箭追着空中屠夫的身体中心飞。中:昆卡从空中的屠夫底下走过去,互不阻挡。右:从上往下看,范围技能的圈不分地上和空中。卡通示意。

一是投射物。弹道总是追着目标的身体中心飞,目标飞得越高,路就越长,打中得越晚。二是阻挡。两个单位只有差不多一样高,才会互相挡路;一个在天上,一个在地上,就各走各的。三是范围技能,它不看高度:一个圈画下去,圈里的单位不管飞得多高,都算在圈里。攻击距离也不看高度。

那为什么被旋风卷起来的人,就打不中呢?不是因为他飞得高,而是因为旋风同时让他“无敌”了。洪流和投掷不给无敌,所以照样挨打。

两个有意思的例外

第一个是蝙蝠骑士。他的模型看起来一直在天上飞,开了“火焰飞行”还能越过悬崖和树。可在规则里,他是一个地面单位,火焰飞行只是让他“无视地形移动”,并不算飞行单位。2025 年底的 7.40 版本在地图边上加了一些挡飞行的阻挡,开着火焰飞行的蝙蝠骑士,也上不去其中某些高台了。

第二个是卓尔游侠。2023 年的 7.33 版本给了她一个技能“冰川”:在脚下垒起一座冰山。站上去的人有飞行视野、攻击距离变远;从下面打上面的人,还要吃“低打高”的丢失。等于说,她能随身带一块高地。

蝙蝠骑士看着在飞规则上:地面单位卓尔游侠的冰川脚下垒起一座冰山随身带一块高地
图 6两个例外。左:蝙蝠骑士的模型飞在天上,可规则只认地上那个圈。右:卓尔在脚下垒起冰山,等于随身带了一块高地。卡通示意。

这两个例子,正好从两头说明了同一件事:在 DOTA2 里,看起来飞不飞、高不高并不重要,规则把你算在哪一层,才重要。

为什么要这样设计

DOTA2 用的是 Valve 的 Source 2 引擎,引擎本身完全能处理真正的三维世界。为什么规则偏偏要压成一个平面,只留几层台阶?

下面是我的理解,不是官方的说法。

一是血统。DOTA 从《魔兽争霸 III》的地图里长出来,那套“平面地图加几层悬崖”的规则,是这个游戏的老底子,改了就不是 DOTA 了。

二是好算。几十个单位同时在地图上找路、互相挡路,在一张一层的平面棋盘上算,比在真正的三维空间里算,简单得多。

三是好看懂。玩家是从斜上方俯视战场的,一眼要看清谁在哪、谁能打到谁。平面规则配上几层台阶,正好对得上这个视角:高地就是“更高的那一层”,不用去猜某个人到底离地几米。

写在最后

DOTA2 的 Z 轴,是一个很克制的设计。三维的画面,平面的规则,中间只留了几层台阶。高度在少数地方说了算:视野、低打高、被抬到空中时的弹道和挡路;其他时候,它只负责好看。

下次你看见队友被冲上天,又被地上的技能补死,就知道了:他在天上待的那一秒多,在游戏的账本里,一直站在原地。

画面是三维的,
规则是平面的。
留言区聊聊

你在 DOTA2 里见过哪些“高度不对劲”的瞬间?

参考资料
  1. Liquipedia Dota 2 Wiki:Forced Movement(Upward Movement)、Vision、Evasion、Unit Size、Map 等词条
  2. Valve Developer Community:Dota 2 Workshop Tools / Level Design / Fog of War、Navigation Mesh(2014)
  3. Liquipedia:Version 7.06、7.22e、7.33、7.40 更新日志
  4. 暴雪《魔兽争霸 III》官方战网攻略:Combat
注:文中插图均为本文自制示意,卡通英雄是本文自己画的,不是游戏里的官方形象。图 4 的小地图和视野规则是本文简化的,格数由本文程序算出,不代表游戏里的真实地图。
犹剑在心
北极甜虾(剑心犹在!)
— 全文完 —
Translated from the Chinese original, “DOTA2 的 Z 轴,到底管什么用?”.
The Logic of Play · No. 3

What Is Dota 2’s
Z-Axis Actually For?

A flat game pretending to be 3D
In Dota 2, an enemy gets launched into the air, and spells on the ground still hit him. This is not a bug: in the game’s ledger, he never left the ground. This essay is about height in Dota 2, the Z-axis: what it controls, what it doesn’t, and why it was designed that way.
What you see: Pudge launched into the airKunkkaPudgeNyx AssassinWhat the game records: Pudge still on the ground
Figure 1Two views of the same moment. Above is what you see on screen: Kunkka’s Torrent launches Pudge into the air, and Nyx Assassin’s Impale comes spiking along the ground toward him. Below is what the game records: each hero is just a circle on the ground, Pudge’s circle hasn’t moved at all, and the strip that Impale sweeps still covers him. The cartoon heroes are chibi-style sketches drawn for this essay, not the game’s official artwork.

Anyone who has played Dota 2 has probably seen this: Kunkka casts Torrent and launches an enemy into the air. While he is still up there, an area spell slams into the ground beneath him, and he gets hit anyway.

The players’ community wiki uses exactly this as an example: a unit launched by Torrent, while still in the air, takes the full hit from Nyx Assassin’s Impale.

Common sense says that if he is up in the air, nothing on the ground should be able to touch him. The answer is buried in the game’s foundations. Dota 2 looks like a 3D game, but most of its rules are computed on a flat map. Height, the Z-axis of 3D coordinates, has the final say in only a few things.

This is the third essay in “The Logic of Play,” a series in which each essay takes apart the logic behind one game. This one sets out to make one thing clear: what Dota 2’s Z-axis actually controls, and what it doesn’t.

The ledger is flat

First, how does the game record where a hero is?

The Dota 2 map is cut into one big chessboard, each square 64 × 64 game units. Whether a hero can get somewhere is worked out on this board: which squares are walkable, and which are blocked by trees, cliffs or buildings. The board has only one layer. It records “can this square be walked on,” never “can this square be walked on at level such-and-such.”

By the rules, a hero’s own “body” is a circle on the ground. According to the figures collected on the community wiki, a typical hero’s collision radius is 27 units: the closest two heroes can get is the two radii added together. Attack range and cast range are measured on the plane as well.

As for how high a hero’s feet are off the ground, most of the time the game doesn’t record it at all. Wherever a hero stands, it is exactly as high as the ground under its feet. The community wiki makes a point of noting that even for flying units, whose models are up in the air, the circle used for collision stays on the ground.

Terrain is stacked in layers

What about the hills and valleys? Also simple: the terrain is a set of steps, stacked up layer by layer.

RiverLaneRiverHigh ground0128256Terrain is stacked in layers, each 128 high (in game units)
Figure 2A cross-section of the terrain, schematic: a ward stands in the river, Kunkka stands in the lane, and Drow Ranger stands on the high ground. According to Valve’s 2014 documentation for custom map makers, walkable ground is built in layers of 128 units, with the river at 0 and the mid lane at 128.

In its 2014 documentation for custom map makers, Valve says that the walkable ground on a map should be built in layers of 128 units. The river sits at the bottom, at height 0, and the mid lane at 128. Fog of war distinguishes at most 32 height levels. On today’s official map, by the community wiki’s count, about six layers really matter for play: the river, low ground, high ground, and above those, still higher platforms like the one the fountain stands on, and so on. Layers are joined by ramps.

Terrain built this way has a fun property.

Why there are no overpasses

High-school math has the “vertical line test.” To see whether a curve is the graph of some function, try it with vertical lines: if every vertical line meets the curve at most once, it is.

Height map: OKEach line hits the ground onceBridge: can’t be doneTwo hits: the deck and below
Figure 3The vertical line test. On the left hillside, every vertical line hits the ground only once; on the right, a single vertical line hits two layers, the bridge deck and the ground beneath it. Schematic.
The ideaOne layer, no overpasses

If a map stores only one ground height for each position on the plane, then it cannot have a place where you can walk on the bridge and also under it.

WhyA person on the bridge and a person under it stand at the same position on the plane, yet their feet are at two different heights. But the map stores only one height for that position, with no room for a second. This is the vertical line test again: a vertical line at that position hits two layers of ground, so the map no longer has “one height per position.”∎

Dota 2’s pathing grid is exactly like this: one layer, with one “walkable or not” per square. So under these rules it is very hard to build overpasses, tunnels, or one floor above another. Patch 7.40, at the end of 2025, put a few bridge models on the map, but I found no claim that units can walk underneath them. Think back over the Dota 2 map, and you probably can’t recall anywhere with one path on top and another path underneath.

Height’s first job: vision

If most rules are computed on the plane, what does height actually control? The most important thing is vision.

The rules are simple to state. From low ground you cannot see ground higher than yours; from high ground you can see most of what lies below. Trees block vision on their own level, and on the level above as well. Flying units have “flying vision,” which neither terrain nor trees can block.

Following these rules, I drew a small simplified map, placed the same ward in three spots, and had a program count how many cells each one can see.

Ward in river: sees 38 cellsWard in lane: sees 100 cellsWard on high-ground edge: sees 100 cellsYellow: visible. Blue: river, gray: lane, dark: high ground; dots: trees
Figure 4The same ward placed in three spots. In the river, the slopes on both sides block it, and it sees only the river itself; in the lane or at the edge of the high ground, it sees a large area. The map and rules are simplified for this essay, and the cell counts were computed by this essay’s program.

The same ward sees only 38 cells from the river, but 100 from the lane. That is why good players love to ward high places: one level up, and you see more than twice as much.

Second: uphill shots can miss

The second thing height controls is attacks.

A ranged attack from low ground at high ground has a 25% chance to miss and hit nothing. The rule is still in the game today, and it applies whether or not you have vision of the target; melee attacks are not affected. Since patch 7.06 in 2017, flying units have been exempt from this penalty, and since patch 7.22e in 2019, the chance has been “pseudo-random,” so you won’t miss too many times in a row.

This rule is older than DotA itself. DotA began as a custom map for Warcraft III, and Blizzard’s official Warcraft III guide already says that ranged units attacking from low ground to high ground have a 25% chance to miss.

Third: units in the air

Back to the scene from the start. Torrent, Tiny’s Toss and the various cyclones all lift a unit into the air, and then its position on the Z-axis really does change. Once it changes, three things are affected.

ProjectilesChase the body centerHigher means laterBlockingBig height gap,no blockingArea spellsAirLandKPIgnore height,still hit
Figure 5What height does and doesn’t control once a unit is lifted into the air. Left: Drow’s arrow chases the body center of the airborne Pudge. Middle: Kunkka walks right under the airborne Pudge, and neither blocks the other. Right: seen from above, an area spell’s circle makes no distinction between ground and air. Cartoon schematic.

First, projectiles. A projectile always flies toward the target’s body center, so the higher the target, the longer the path and the later the hit. Second, blocking. Two units block each other only when they are at about the same height; if one is in the air and the other on the ground, each goes its own way. Third, area spells, which ignore height: draw a circle, and every unit inside it counts, however high it is flying. Attack range ignores height too.

So why can’t you hit someone lifted up by a cyclone? Not because he is high up, but because the cyclone also makes him “invulnerable.” Torrent and Toss don’t grant invulnerability, so their targets still take hits.

Two interesting exceptions

The first is Batrider. His model always looks as if it is flying, and with Firefly on, he can even cross cliffs and trees. By the rules, though, he is a ground unit: Firefly only lets him move without being blocked by terrain; it does not make him a flying unit. Patch 7.40, at the end of 2025, added some blockers against flying movement along the edges of the map, and even Batrider with Firefly on can no longer get up onto some of those raised ledges.

The second is Drow Ranger. In 2023, patch 7.33 gave her an ability called Glacier, which raises a hill of ice under her feet. Units standing on it get flying vision and longer attack range, and anyone attacking them from below suffers the uphill miss chance. In effect, she carries a piece of high ground around with her.

BatriderLooks airborneBy the rules: a ground unitDrow Ranger’s GlacierRaises an ice hill underfootPortable high ground
Figure 6Two exceptions. Left: Batrider’s model flies in the air, but the rules only recognize the circle on the ground. Right: Drow raises a hill of ice under her feet, in effect carrying a piece of high ground with her. Cartoon schematic.

These two cases show the same thing from opposite ends. In Dota 2, it doesn’t matter whether you look like you are flying or how high you appear to be. What matters is which layer the rules put you on.

Why design it this way?

Dota 2 runs on Valve’s Source 2 engine, which can handle a truly 3D world perfectly well. So why do the rules insist on squashing everything into a plane, with only a few steps left?

What follows is my own reading, not an official explanation.

First, lineage. DotA grew out of a Warcraft III map, and its rules of “a flat map plus a few tiers of cliffs” are the game’s old foundation. Change them, and it would no longer be Dota.

Second, it is easy to compute. With dozens of units finding paths and blocking each other at the same time, working it all out on a flat, single-layer board is far simpler than doing it in true 3D space.

Third, it is easy to read. Players look down on the battlefield from above and at an angle, and need to see at a glance who is where and who can hit whom. Flat rules plus a few steps match this view exactly: high ground is simply “the higher layer,” and nobody has to guess how many meters off the ground someone is.

In closing

Dota 2’s Z-axis is a very restrained design: 3D visuals, flat rules, and only a few steps in between. Height has the final say in just a few places: vision, the uphill miss chance, and projectiles and blocking once a unit is lifted into the air. The rest of the time, its only job is to look good.

So the next time you see a teammate launched into the air and then finished off by a spell on the ground, you will know: for the second or so he spent up there, in the game’s ledger he was standing right where he started.

The picture is 3D,
the rules are flat.
Let’s talk in the comments

What moments in Dota 2 have you seen where the height seemed “off”?

References
  1. Liquipedia Dota 2 Wiki: pages including Forced Movement (Upward Movement), Vision, Evasion, Unit Size and Map
  2. Valve Developer Community: Dota 2 Workshop Tools / Level Design / Fog of War, Navigation Mesh (2014)
  3. Liquipedia: Version 7.06, 7.22e, 7.33, 7.40 patch notes
  4. Blizzard, official Warcraft III guide on Battle.net: Combat
Note: all illustrations are schematics made for this essay; the cartoon heroes were drawn by the author and are not the game’s official artwork. The small map and vision rules in Figure 4 are simplified for this essay, and the cell counts were computed by this essay’s program; they do not represent the real map in the game.
犹剑在心
北极甜虾(剑心犹在!)
— The End —

← All essays