(翻譯)游戲雙搖桿:輔助瞄準: Everything I Learned About Dual-Stick Shooter Controls
Everything I Learned About Dual-Stick Shooter Controls
Dual-stick shooter controls on a gamepad should be a completely solved problem by now, shouldn’t they? When I started developing my open-source game Relic Hunters Zero on my spare time last year, I was very surprised to realise that I’d have to bang my head against multiple walls to get everything up to an acceptable level of quality. Granted, there are a few good bits of information here and there on the internet, but it’s all very scattered and hardly enough for a first-timer on the genre like me.
雙搖桿射擊現在有成熟的解決方案。
Now that the game is nearing its release I decided I might as well aggregate, in a single article, all knowledge I gained on the subject through research, trial and error, and mostly by obsessing over the tiny details that make all the difference.
這篇文章是我調研后的總結。
Zero is the major example I’ll use below, but you’ll find that it’s a good one - it contains pretty much all of the tropes and control scheme challenges in the genre. So strap your belts, grease your control sticks and let’s get on with it, shall we?
我的游戲Zero是很好的例子。
Understanding Axes and Implementing Deadzones Correctly
理解Axes并正確實現Deadzones
Analog stick input is composed by two axes (usually “x” axis and “y” axis) with values that range from -1 to 1. “0” is the absolute center, while “1” or “-1” represent the very edges of the stick, either up/down or left/right. By combining these two axes we get 360-degree directional input with an “intensity” value that ranges from 0 to 1.
搖桿輸入由x、y軸組成,每個軸的值在[-1,1]之間。0是每個Axes的中心。在二維平面上我們可以獲取360度的朝向。
So what is a “deadzone”, you ask? When you are not touching the stick, even the best possible gamepad won’t give you a perfect “0” value for any of the two axes. What you normally get is a frenetic value switch, usually on the 0.05 to 0.15 scale on quality hardware. So if you just use that raw input in your game - say, for movement - you will see your character twitching in all directions like a pudding having a seizure.
即使手柄硬件再好,當你不操作搖桿時,獲取的值也不是精確的(0,0),
通常在 0.05到0.15之間。直接用純粹的數據控制player移動可能會導致沒有輸入的時候player在抽搐。
(使用unity有個dead值的配置去控制此問題 )
https://docs.unity3d.com/Manual/class-InputManager.html
That’s when the deadzone comes in. We ignore all values below a certain threshold, smoothing out the rough patches of the input. The idea itself is pretty simple, but you would be surprised at how often it is implemented the wrong way! Actually, on both the engines I normally use (Game Maker: Studio and Unity) I find deadzones to be handled poorly, so I tend to get raw XInput data and code the deadzones myself.
比較簡單的做法是超過deadzone定義的閾值后再響應輸入。不過作者發現unity處理的并不太好。準備自己實現
On my first implementation I made the rookie mistake of just checking each individual deadzone to see if either one is above my desired threshold. For example, if it’s a 0.3 deadzone, my code would be something like this:
if ( Math.abs(joy_get_axisX()) > 0.3 ) || ( Math.abs(joy_get_axisY()) > 0.3 )
{
DoTheStuff();
}
第一版實現作者犯了個新手錯誤,直接判斷閾值。
下面的實現更不對:
if ( Math.abs(joy_get_axisX()) > 0.3 )
{
DoTheXStuff();
}
if ( Math.abs(joy_get_axisY()) > 0.3 )
{
DoTheYStuff();
}
Sutphin’s article goes on to offer an even more sophisticated model, which he calls “Scaled Gradient Deadzone”, based on the idea of smoothly “killing” the input instead of instantly dropping off to 0 when the deadzone is reached. While it is an amazing tool for a FPS game, I found it to be overkill for Relic Hunters Zero, so after a few tests I ended up sticking with the simple radial deadzone. In fact, let’s talk more about what I’ve learned, and the differences between FPS and dual-stick shooter controls.
Sutphin的文章繼續提供了一個更復雜的模型,他稱之為“縮放梯度deadZone”,基于平滑地“Kill”輸入,而不是在magitue到達deadZone時立即降為0的想法。不過作者測試后,發現直接用magitue對自己游戲體驗更好。
我找到了一個實現:
https://gist.github.com/DataGreed/c7c7c15d2cf009bc63966e60f44be522
分析InputWithRadialDeadZone和InputWithScaledRadialDeadZone區別:

Analog vs. Digital Input
A constant lesson for me was that concepts that are perfectly fine for digital input don’t always translate well for analog. As a huge fan of FPS games, I came into Relic Hunters eager to try a lot of neat control tricks that make these games feel great, usually to no avail
So let’s begin by understanding how FPS aiming is different from dual-stick shooter aiming. In first-person-shooters, input is digital - there is no direct correlation between the position of the sticks (intensity and direction) and the position of the crosshair (a pair of coordinates on a cartesian plane). Dual-stick Shooters are analog - the firing direction correlates with the direction of the stick.
雙搖桿射擊方向和搖桿方向是相關的。
固定視角的FPS游戲(射擊十字在屏幕中心),搖桿的方向、強度和準心的位置不是直接關聯的。

Analog/Digital vs. Analog/Analog comparison
This changes everything. First of all, as I’ll demonstrate below, assisted aiming becomes a real challenge. Also, the player is always holding the input down! While in FPS games you can “rest” your right stick after you place the crosshair where you want it, in dual-stick shooters you have to keep holding it.
雙搖桿游戲你必須一直握著Stick,FPS游戲中設定好方向后就可以放下搖桿了。
This means that you can never expect players to use the right-stick and the face buttons (XYAB on Xbox, Square/X/Triangle/Circle on Playstation) at the same time. Any actions that need to be executed while you aim must be mapped to the triggers and shoulder buttons, so we have to design accordingly. Of course, mapping is a matter of preference (you should always offer your players the option to remap their controls), but you have to make sure that you don’t have more than 3 or 4 commands (ideally 2) in your design that must be executed while aiming.
這意味著你永遠不能期望玩家同時使用右搖桿和正面按鈕(Xbox上的XYAB, Playstation上的方形/X/三角形/圓形)。
當你瞄準目標時,任何需要執行的動作都必須映射到Botton和Top按鈕上,所以我們必須相應地進行設計,當然,映射是一個偏好問題(你應該總是為玩家提供重新映射控制的選擇),但你必須確保你的設計中不包含超過3或4個命令(理想情況下是2個),這些命令必須在瞄準時執行
A great rule of thumb (no pun intended) that makes up most of the good feel of Relic Hunters’ controls is that the aim must never, EVER snap into position. If you translate stick input directly into in-game look direction you will get very jaggy results that look and feel awful.
如果你將Aim搖桿輸入直接轉換為Player Look方向,你將得到非常粗糙的結果,看起來和感覺都很糟糕
So, my first commandment: directional input should always be interpolated. Even very high-speed rotation (say 12 degrees per frame in a 60fps game) feels much better than snapping towards the input position
方向輸入總應該被插值,即使幀率非常高。(作者下文又推翻了這個準則)
搖桿輸入和player朝向的插值,如下圖:

Gap between input direction and in-game direction
The way I do it is to have two different directions: a “target” direction that comes straight from input, and a “view” direction that is displayed in-game, and rotates towards the target direction with a set speed. I also recommend having a “minimum difference” between the two values before moving, which will compensate for the tiny variations on axis value that you may get from hardware.
同時建議兩個方向超過最小minimum difference后才進行插值,用于補償硬件的輕微抖動(輕微的角度差不進行插值)
The speed with which we rotate this “view” direction is the “aim sensitivity”. Higher sensitivity will give you snappy, agile input with smaller precision, while lower sensitivity will rotate slowly providing you with increased accuracy at the expense of responsiveness.
Aim 靈敏度:我們把player旋轉朝向的速度定義為Aim靈敏度,高靈敏度會較小的精度提供快速輸入,低靈敏度會讓player旋轉比較慢,不過玩家的精確度會高一些。
One neat trick that I soon learned is that you don’t have to choose - at least not all the time. Just as FPS games change aiming sensitivity depending on the situation, so can dual-stick shooters! In relic hunters I use a high sensitivity when you just move the right stick to aim, but a much lower one when you hold Left Trigger to enter the special “laser sight aiming” mode. I also zoom in and move the camera a little bit towards the aiming direction to better communicate and smooth out the transition.
作者的策略是:只移動RightJoyStick進行瞄準的時候,提高靈敏度,但是當玩家按LT開啟Laser激光瞄準的時候,作者使用了低靈敏度,并且拉近一點點Carmera. (作者的這個游戲是 右搖桿沒有激光瞄準線,LT會開啟激光瞄準線)

Two different aiming modes in Relic Hunters Zero
But that’s not all you can do. There’s a very cool aim assist tool in console first-person shooters called “Sticky Aim”. The idea is to give you an invisible helping hand by detecting that your crosshair is on top of an enemy and then dramatically decreasing aiming sensitivity - this way you can acquire targets and keep them in your crosshair much more easily. You can see this trick while aiming in gamepad-focused shooters such as Halo 3 and Borderlands 2, and it is even used in Destiny’s mouse-like interface to help you click on the butto
還有一種(Sticky Aim)的輔助方式
"Sticky Aim"(粘性瞄準)和"Auto Aim"(自動瞄準)是射擊游戲中兩種輔助瞄準功能,它們都旨在幫助玩家更容易地鎖定目標,但它們的工作方式有所不同:
-
Sticky Aim(粘性瞄準):
- 粘性瞄準是一種當玩家的瞄準準星接近敵人時,游戲會稍微減慢準星移動速度的機制。這種減速效果使得準星在敵人附近"粘住",從而幫助玩家進行微調以準確瞄準。
- 這種機制通常比較微妙,不會直接將準星吸附到目標上,而是為玩家提供了在接近目標時更精確瞄準的可能性。
- 粘性瞄準主要在使用控制器時體現其效用,因為與鼠標相比,控制器的精確瞄準更具挑戰性。
-
Auto Aim(自動瞄準):
- 自動瞄準是一種更直接的瞄準輔助。當玩家的瞄準準星接近敵人時,游戲可能會自動調整準星,直接對準敵人。
- 這種機制通常在玩家射擊時觸發,游戲自動將準星移動到最近的目標上。
- 自動瞄準提供了更明顯的輔助,對新手玩家或是希望減輕瞄準難度的玩家更加友好。
總的來說,粘性瞄準提供了一種更微妙的輔助,它不會直接瞄準,而是減慢準星移動速度,幫助玩家進行精準瞄準。相比之下,自動瞄準提供了更直接的幫助,它會自動將準星對準目標,減少了玩家需要進行的瞄準操作。選擇使用哪種瞄準輔助或兩者的結合,取決于游戲設計師的意圖和游戲的目標受眾。
That’s the whole idea, actually. The best control scheme in my opinion is the one that offers maximum success to players while giving them a clear impression that they are doing all the work - any assisted aiming should be as invisible as possible.
輔助瞄準盡可能的無感知。
Unfortunately, “sticky aim” did not solve Relic Hunters Zero’s aiming completely, so I also had to look for an actual “auto-aim” solution that directly changed the aiming direction. That’s when it got tricky.
“sticky aim”沒有徹底解決作者的問題,作者需要一種auto aim的方式。
My first instinct was to keep the “invisible” approach as I tried to emulate Destiny’s best-in-class aim system: a combination between sticky aim, large hitboxes and a gentle “nudge” of the aim towards valid targets.
作者第一種嘗試是保持“invisible”, “sticky aim” + “large hitboxes”+ “輕推”搖桿
I spent a lot of hours trying to make it work before I gave up. Ultimately what I did was adding a third value to the aim direction: besides the “input” and the “view” values, I’d have an “auto-aim offset” that tried to compensate for differences between the player’s input and the target position. It slowly “nudged” the direction towards the enemies and at first it worked brilliantly! Accuracy was excellent and the feeling of control was great.
作者添加了第三個參數“自動瞄準偏移”,去彌補玩家的輸入和目標朝向之間的差異,這樣會慢慢推動到enemy的方向,初始感覺還不錯。

The problem is that, in an analog control scheme, player directional input is always held, remember? So when the enemy dies or gets out of range, there is a gap there between input and in-game direction created by the auto-aim. My first solution was to smoothly “return” the aim offset to zero, but testing resulted in a lot of players reporting that the aim was “weird and moved by itself”.
但這樣造成問題,當目標丟失或者死亡的時候,由于自動瞄準朝向和InputDirection存在差異,作者將當前AimDirection平滑的插值返回到InputDirection,但測試反饋不理想,玩家表示AimSystem很奇怪,自己在動。
Worse - at times players would “fight” against the auto-aim, and the laser sight would jitter up and down. My last resort was NOT removing the gap until the player let go of the stick - that is, after auto-aiming, there would be a constant offset between the input and the in-game direction. I hope this would maybe go unnoticed, but it wasn’t the case. The gap could get pretty wide when engaging multiple enemies, and even if it didn’t I was underestimating the precision of human muscle memory: players would try aiming at the same direction they just did a second before, and get different results. It was not acceptable.
更糟糕的是有時候玩家會“對抗”自動瞄準。激光線會上下抖動。作者讓玩家松開搖桿之前不清理偏移,但是這回導致和多個enemies交戰的時候,偏移會越來越大。作者低估了人類肌肉記憶的準確性:玩家會嘗試瞄準相同的方向,卻得到不同的結果,這是不可接受的。
The final solution? Breaking my first commandment. Turns out that using a relatively narrow auto-aim angle (about 30 degrees) and instantly snapping towards the enemy while changing the color of the laser sight was the best solution. Messing with the directional input was always unnatural, so trying to mask it was a fool’s errand - I found out that it was much better to clearly communicate to players that auto-aiming is taking place, and let it do its thing.
作者的解決方案:放棄一定需要平滑插值的準則 ,限定auto aim的相對角度是30度,并直接把瞄準線閃過去并修改顏色。明確的告知玩家當前是有自瞄發生的。
The narrow range makes sure that switching between targets can be done smoothly without the player feeling that the aim is “stuck” somewhere, and it gave that extra edge that controller input needed to be as accurate as the mouse. I’d prefer if the system was invisible, but that was the best solution I could come up with at the time. Also, players can disable both this auto-aim system and the sticky aim in the game’s Settings menu if they want to.
狹窄的范圍確保切換目標的時候不會太突兀。玩家可以在設置中禁用自動瞄準和粘性瞄準。
More auto-aiming challenges
My first naive implementation of auto-aim had a minimum angle, and it just checked the angular difference between the player’s input and the target direction. If it was smaller than the minimum angle, I turned on the auto-aim. Simple, right? And also completely wrong.
作者的第一種自動瞄準方式,有個最小角度,檢查玩家的inputJoystick和TargetDireciton之間的角度差,如果小于最小角度,就打開自動瞄準,這簡單但也是錯誤的。
What actually happens is that players would get MORE accurate the further they were from enemies. This is because the angular difference diminishes with the square of the distance (or something like that, I hope my mathematician friends don’t hang me).
當距離越遠,這個觸發就會越頻繁。因為隨著距離的增加,角度會變小。
如下圖,距離越遠的時候,即使搖桿輸入角度偏離更大了,也被觸發自瞄了。

On the example above you can see that even though the player’s directional input and the angle towards the enemy was the same, the actual angular difference was far from it! Unfortunately, my sloppy code did not differentiate between these two cases, so I ended up with an auto-aim system that was either useless at close range or completely ubiquitous at long range.
I solved this by “projecting” the player’s directional input towards the target first, and then checking that final angle against my minimum auto-aim angle.
作者解決的方式 如下圖:計算和目標圓交點的夾角。

Correct: different situations, different results
“A Good Feel Is A Hack”
I usually tell people - especially well-trained programmers that are cursed with having to work with me - that “A Good Feel Is A Hack”. When programming controls and feedback for games, it is tempting to try and make everything work with simple, all-encompassing rules, just like real-life.
The sad fact though is that real-life feels like s***
我經常告訴人們——特別是那些被詛咒必須和我一起工作的訓練有素的程序員——“良好的感覺是一種Hack”。當為游戲編寫控制和反饋時,我們很容易嘗試使用簡單的、包羅萬象的規則,就像現實生活中那樣。
可悲的事實是,現實生活感覺就像一坨屎
We want our games to feel smooth and larger than life, and often that will translate into a lot of special cases and ugly “ifs” in your otherwise pristine control code. Don’t be afraid of them! This is general advice, so the best I can do is offer a few examples.
In Relic Hunters Zero, my camera tracks a “sweet spot” between the player position and the aiming position. It works great for mouse input (digital, remember?), but I had to make a lot of exceptions for analog sticks. For instance, there was a small and snappy camera movement that happened every time the player switched movement direction, and it was distracting - so I went into the code and wrote a special exception so that the camera would ignore the crosshair position unless the player was not moving OR not using the right analog stick OR the distance was below a certain threshold. Ugly, but effective.
我們希望我們的游戲看起來更流暢、更宏大,這通常會導致你的控制代碼中出現許多特殊情況和丑陋的“如果”。不要害怕他們!
例如,每當玩家切換移動方向時,都會出現一個小而快速的攝像機移動,這令人分心——所以我編寫了代碼并編寫了一個特殊的例外情況,以便攝像機將忽略準線位置,除非玩家沒有移動或沒有使用正確的模擬操縱桿或距離低于某個閾值。丑陋,但有效。
Another example: my game has a digital crosshair as well as directional input (more on that on the next section). If you have auto-aim turned off or you use the subtle “assist” mode which uses the narrow angle I mentioned before, the digital crosshair stays at a distance to the player relative to the length of the stick’s directional vector. For the “full” auto-aim mode, however, I found out that it was better to communicate which enemy was being targeted, so I snap the digital crosshair to be straight on top of the enemy. This exception caused the camera to behave weirdly though, so I coded in yet another exception for the camera to ignore the crosshair when in “full” auto-aim unless the player is aiming or using the right stick.
In conclusion, a good game feel usually revolves around these small touches as you polish the rough edges of the experience. Players don’t care how elegant your code is, they just want smooth controls and feel - just make sure to document your “hacks” well and code maintenance won’t be a problem.
總而言之,優秀的游戲感覺通常圍繞著這些小細節,因為你可以打磨游戲體驗的粗糙邊緣。玩家不關心你的代碼有多優雅,他們只想要流暢的控制和感覺-只要確保你的“hack”文檔很好,代碼維護不會是問題。
Digital Crosshair With Directional Input
I have just spoiled this in the previous sections, but Relic Hunters Zero has two types of aiming: regular and laser sight. Laser sight is 100% analog - it simply draws a red line corresponding to the input direction from the controller.
而“常規”瞄準則試圖通過數字準星模擬鼠標輸入。我的做法是,準星與玩家之間有一個最大和最小的距離,這是由stick與deadarea之間的距離所決定的。這是一種讓玩家感覺良好并幫助他們檢查周圍環境的簡單方法,因為攝像機會隨著準星與玩家角色的距離而移動。
Camera Ease-in and Ease-out
接下來文章內容 作者說了很多carmera平滑的事情。
總結起來就是插值。
Give The Game A Rest
Playtesting your game with complete strangers is extremely valuable!
讓完全陌生的人測試你的游戲非常有價值!
I’m not saying that controls can’t be improved with player feedback - they definitely can, and you’ve just read about player testing helping me in pretty much all of the points of this article. A good rule of thumb I use (for feel and for everything else) is that if 3 or more people independently complain about something in your game, you most likely have a serious problem worth looking into.
如果3個或3個以上的人獨立地抱怨你的游戲中的某些內容,那么你很可能存在一個值得調查的嚴重問題。(不包含相關的游戲制作人員,會帶有主觀印象)
Nevertheless, the designer is still the most important pair of eyes and hands when tuning the feel and controls of the game, so it’s very important to keep your perspective fresh. Take some time off (usually between a week and a month works for me), play other games, do other stuff, and then come back and check how well your controls and your feel are holding up
盡管如此,在調整游戲的感覺和控制時,設計師仍然是最重要的眼睛和手,所以保持視角的新鮮感非常重要。休息一段時間(對我來說通常是一周到一個月),玩其他游戲,做其他事情,然后回來檢查你的控制和感覺是否良好
I’m not telling you to stop working on the game! Even when we are part of a team, it’s hard to have that luxury. As a solo developer, I usually shifted my focus elsewhere, coding a menu system, or a save system, or audio system - whatever kept me off the controls.
我并不是要你停止開發游戲!即使我們是團隊中的一員,也很難有那種奢侈。作為一名獨立開發者,我通常會將注意力轉移到其他地方,編寫菜單系統、保存系統或音頻系統——任何讓我遠離控制的東西
If your game has support for both keyboard/mouse and gamepad, it’s also helpful to switch between them when developing. In Relic Hunters I would use only the mouse for a week, and then as I switched back to the controller I would notice several issues with it, and vice-versa.
如果你的游戲同時支持鍵盤/鼠標和手柄,那么在開發過程中切換它們也是很有幫助的。在《Relic Hunters》中,作者將只使用鼠標一周,然后當我切換回控制器時,我將注意到它的一些問題,反之亦然。

浙公網安備 33010602011771號