Skip to content

Commit

Permalink
Some adjustments to the drums kick flash animation's playback (YARC-O…
Browse files Browse the repository at this point in the history
…fficial#434)

* Adjust when the drums kick flash/shake plays
Now only plays when outside of the chart or when actually hitting a kick

* Fix kick flash animation updating slower than intended at low FPS
  • Loading branch information
TheNathannator authored Jun 6, 2023
1 parent 78f2088 commit 045a2b4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
20 changes: 14 additions & 6 deletions Assets/Script/PlayMode/DrumsTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,14 @@ private void DrumHitAction(int drum, bool cymbal) {
drums[drum].Pulse();
} else {
PlayKickFretAnimation();

if (shakeOnKick) {
//commonTrack.PlayKickCameraAnimation();
trackAnims.PlayKickShakeCameraAnim();
// Only play kick flash/shake now when outside of the chart,
// otherwise only play it when actually hitting a kick
if (Chart.Count < 1 || CurrentTime < Chart[0].time || CurrentTime >= Chart[^1].time) {
commonTrack.kickFlash.PlayAnimation();
if (shakeOnKick) {
trackAnims.PlayKickShakeCameraAnim();
}
}

commonTrack.kickFlash.PlayAnimation();
}

// Overstrum if no expected
Expand All @@ -329,6 +330,13 @@ private void DrumHitAction(int drum, bool cymbal) {
if (note.isActivator) {
(input as DrumsInputStrategy).ActivateStarpower();
}
// Play kick flash/shake
if (note.fret == kickIndex) {
commonTrack.kickFlash.PlayAnimation();
if (shakeOnKick) {
trackAnims.PlayKickShakeCameraAnim();
}
}
break;
}
}
Expand Down
11 changes: 3 additions & 8 deletions Assets/Script/PlayMode/KickFlashAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,11 @@ private void UpdateTexture() {
}

private void Update() {
if (_currentSprite >= _textures.Length) {
return;
}

if (_updateTimer > SecondsPerFrame) {
_updateTimer = 0f;
_updateTimer += Time.deltaTime;
while (_updateTimer >= SecondsPerFrame && _currentSprite < _textures.Length) {
_updateTimer -= SecondsPerFrame;
UpdateTexture();
_currentSprite++;
} else {
_updateTimer += Time.deltaTime;
}
}

Expand Down

0 comments on commit 045a2b4

Please sign in to comment.