babalae/better-genshin-impact · error · InvalidOperationException
横向移动偏移量校准失败
Error message
横向移动偏移量校准失败
What it means
InvalidOperationException from AutoTrackPathTask.DoTask when GetOffsetAngle() returns 0. GetOffsetAngle moves the mouse horizontally by CharMovingUnit units, presses W briefly, then computes angle2-angle1 via CharacterOrientation.Compute on the minimap. A zero result means the character's heading did not change at all after the simulated move — the calibration is unusable, so straight-line tracking cannot proceed.
Source
Thrown at BetterGenshinImpact/GameTask/AutoTrackPath/AutoTrackPathTask.cs:127
// 1. 传送到最近的传送点
var first = _way.WayPointList[0]; // 解析路线,第一个点为起点
await new TpTask(_ct).Tp(first.Pt.X, first.Pt.Y);
// 2. 等待传送完成
Sleep(1000);
NewRetry.Do((Action)(() =>
{
var ra = TaskControl.CaptureToRectArea();
var miniMapMat = GetMiniMapMat(ra) ?? throw new RetryException("等待传送完成");
}), TimeSpan.FromSeconds(1), 100);
Logger.LogInformation("传送完成");
Sleep(1000);
// 3. 横向移动偏移量校准,移动指定偏移、按下W后识别朝向
var angleOffset = GetOffsetAngle();
if (angleOffset == 0)
{
throw new InvalidOperationException("横向移动偏移量校准失败");
}
// 4. 针对点位进行直线追踪
var trackCts = new CancellationTokenSource();
_ct.Register(trackCts.Cancel);
var trackTask = Track(_way.WayPointList, angleOffset, trackCts);
trackTask.Start();
var refreshStatusTask = RefreshStatus(trackCts.Token);
refreshStatusTask.Start();
var jumpTask = Jump(trackCts.Token);
jumpTask.Start();
await Task.WhenAll(trackTask, refreshStatusTask, jumpTask);
}
private MotionStatus _motionStatus = MotionStatus.Normal;
public Task Jump(CancellationToken trackCt)View on GitHub (pinned to a7cb36712d)
Solutions
- Ensure the character is standing on open, flat ground at the calibration moment (no wall/freeze).
- Run the tool with sufficient privileges so SendInput reaches Genshin; confirm input injection works.
- Confirm the game window has foreground focus during calibration.
- Clear any overlay occluding the minimap region GetMiniMapMat reads.
- Retry the task — a transient cutscene/loading stall at calibration time yields angleOffset 0.
Defensive patterns
Strategy: retry
Try / catch
try { var offset = GetOffsetAngle(); }
catch (InvalidOperationException e) when (e.Message.Contains("横向移动偏移量校准失败"))
{ /* re-position avatar to open ground, ensure focus, retry calibration */ } Prevention
- Run calibration only on open flat ground with the character free to move.
- Confirm SendInput reaches the game (privileges + foreground focus) before tracking.
- Validate the minimap/PaimonMenu template matches before entering calibration.
When it happens
Trigger: Minimap heading (CharacterOrientation.Compute) returned the same angle before and after the move because the move was blocked (wall/cutscene), the minimap template failed to match in both samples, or SendInput mouse/keyboard did not reach the game (input injection blocked).
Common situations: Character against a wall during calibration so W produces no rotation; SendInput blocked by an overlay with input focus; game running as admin so the app cannot inject; minimap occluded; GetCharacterOrientationAngle threw 'not in main UI' earlier and the value defaulted.
Related errors
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/8538d980ce401fa0.
Report an issue: GitHub.