Skip to content

[BUGFIX] Fix the Playback Speed causing weird behavior during Playtesting #5107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions source/funkin/play/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,9 @@ class PlayState extends MusicBeatSubState
{
initStage();
initCharacters();

// Set animation speed AFTER initializing the characters, so that their animation speeds get updated too.
currentStage.animationSpeed = playbackRate;
}
else
{
Expand Down Expand Up @@ -861,7 +864,11 @@ class PlayState extends MusicBeatSubState
vocals.playerVolume = 1;
vocals.opponentVolume = 1;

if (currentStage != null) currentStage.resetStage();
if (currentStage != null)
{
currentStage.resetStage();
currentStage.animationSpeed = playbackRate;
}

if (!fromDeathState)
{
Expand Down Expand Up @@ -929,7 +936,7 @@ class PlayState extends MusicBeatSubState
Conductor.instance.formatOffset = 0.0;
}

Conductor.instance.update(Conductor.instance.songPosition + elapsed * 1000, false); // Normal conductor update.
Conductor.instance.update(Conductor.instance.songPosition + elapsed * 1000 * playbackRate, false); // Normal conductor update.

// If, after updating the conductor, the instrumental has finished, end the song immediately.
// This helps prevent a major bug where the level suddenly loops back to the start or middle.
Expand Down
19 changes: 19 additions & 0 deletions source/funkin/play/stage/Stage.hx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,25 @@ class Stage extends FlxSpriteGroup implements IPlayStateScriptedClass implements
return _data?.cameraZoom ?? 1.0;
}

/**
* The animation speed of objects.
*/
public var animationSpeed(default, set):Float = 1.0;

function set_animationSpeed(value:Float)
{
for (member in this.members)
{
if (member?.animation == null) continue;
member.animation.timeScale /= this.animationSpeed;
member.animation.timeScale *= value;
}

this.animationSpeed = value;

return animationSpeed;
}

var frameBufferMan:FrameBufferManager;

/**
Expand Down
Loading