Skip to content

Commit eb3ca2b

Browse files
Fix OsuModAutopilot spinner tracking by improving frame following logic
The previous frame following logic in OsuModAutopilot.Update was insufficient for high-frequency replay frames (such as those generated for spinners), causing the cursor to lag behind and effectively stay stationary during spin sequences. This change replaces the `if` check with a `while` loop, allowing the autopilot to skip multiple replay frames in a single update if necessary to catch up to the current gameplay time. This ensures that the spinner motion encoded in the replay frames is correctly executed. Also removed the TODO comment regarding spinner implementation as it is now functional. Co-authored-by: winnerspiros <1675249+winnerspiros@users.noreply.github.com>
1 parent c9a50b4 commit eb3ca2b

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

osu.Game.Rulesets.Osu/Mods/OsuModAutopilot.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
1+
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
22
// See the LICENCE file in the repository root for full licence text.
33

44
using System;
@@ -50,13 +50,20 @@ public void Update(Playfield playfield)
5050
// Very naive implementation of autopilot based on proximity to replay frames.
5151
// Special case for the first frame is required to ensure the mouse is in a sane position until the actual time of the first frame is hit.
5252
// TODO: this needs to be based on user interactions to better match stable (pausing until judgement is registered).
53-
if (currentFrame < 0 || Math.Abs(replayFrames[currentFrame + 1].Time - time) <= Math.Abs(replayFrames[currentFrame].Time - time))
53+
while (currentFrame < replayFrames.Count - 1)
5454
{
55-
currentFrame++;
56-
new MousePositionAbsoluteInput { Position = playfield.ToScreenSpace(replayFrames[currentFrame].Position) }.Apply(inputManager.CurrentState, inputManager);
55+
if (currentFrame < 0 || Math.Abs(replayFrames[currentFrame + 1].Time - time) <= Math.Abs(replayFrames[currentFrame].Time - time))
56+
{
57+
currentFrame++;
58+
}
59+
else
60+
{
61+
break;
62+
}
5763
}
5864

59-
// TODO: Implement the functionality to automatically spin spinners
65+
if (currentFrame >= 0)
66+
new MousePositionAbsoluteInput { Position = playfield.ToScreenSpace(replayFrames[currentFrame].Position) }.Apply(inputManager.CurrentState, inputManager);
6067
}
6168

6269
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)

0 commit comments

Comments
 (0)