BTSDS: Fine tuning for block animation timing.

This commit is contained in:
Jenny Crowe 2022-02-18 07:32:38 -07:00
parent 6ca364d5a0
commit 35a15b04af
2 changed files with 7 additions and 4 deletions

View file

@ -24,7 +24,7 @@ namespace RhythmHeavenMania.Games.BuiltToScaleDS
{ {
if (!moving) return; if (!moving) return;
var windupBeat = createBeat + (createLength * 3.5f); var windupBeat = createBeat + (createLength * 4f);
var hitBeat = windupBeat + createLength; var hitBeat = windupBeat + createLength;
var currentBeat = Conductor.instance.songPositionInBeats; var currentBeat = Conductor.instance.songPositionInBeats;

View file

@ -74,7 +74,7 @@ namespace RhythmHeavenMania.Games.BuiltToScaleDS
var ev = blockEvents[i]; var ev = blockEvents[i];
if (spawnedBlockEvents.Contains(ev)) continue; // Don't spawn the same blocks multiple times. if (spawnedBlockEvents.Contains(ev)) continue; // Don't spawn the same blocks multiple times.
var spawnBeat = ev.beat - (ev.length * 0.5f); var spawnBeat = ev.beat - ev.length;
if (currentBeat > spawnBeat && currentBeat < ev.beat + ev.length) if (currentBeat > spawnBeat && currentBeat < ev.beat + ev.length)
{ {
SpawnBlocks(spawnBeat, ev.length); SpawnBlocks(spawnBeat, ev.length);
@ -125,18 +125,21 @@ namespace RhythmHeavenMania.Games.BuiltToScaleDS
const int blockFramesPerSecond = 24; const int blockFramesPerSecond = 24;
const int blockHitFrame = 39; const int blockHitFrame = 39;
const int blockTotalFrames = 80; const int blockTotalFrames = 80;
const int spawnFrameOffset = -3;
List<int> criticalFrames = new List<int> { 7, 15, 23, 31, 39, 47 }; List<int> criticalFrames = new List<int> { 7, 15, 23, 31, 39, 47 };
public void SetBlockTime(Blocks blocks, float spawnBeat, float length) public void SetBlockTime(Blocks blocks, float spawnBeat, float length)
{ {
float spawnTimeOffset = (float)spawnFrameOffset / (float)blockFramesPerSecond;
float secondsPerFrame = 1f / blockFramesPerSecond; float secondsPerFrame = 1f / blockFramesPerSecond;
float secondsToHitFrame = secondsPerFrame * blockHitFrame; float secondsToHitFrame = secondsPerFrame * blockHitFrame;
float secondsPerBeat = Conductor.instance.secPerBeat; float secondsPerBeat = Conductor.instance.secPerBeat;
float secondsToHitBeat = secondsPerBeat * 4.5f * length; float secondsToHitBeat = secondsPerBeat * 5f * length + spawnTimeOffset;
float speedMult = secondsToHitFrame / secondsToHitBeat; float speedMult = secondsToHitFrame / secondsToHitBeat;
float secondsPastSpawnTime = secondsPerBeat * (Conductor.instance.songPositionInBeats - spawnBeat); float secondsPastSpawnTime = secondsPerBeat * (Conductor.instance.songPositionInBeats - spawnBeat) + spawnTimeOffset;
float framesPastSpawnTime = blockFramesPerSecond * speedMult * secondsPastSpawnTime; float framesPastSpawnTime = blockFramesPerSecond * speedMult * secondsPastSpawnTime;
// The only way I could deal with Unity's interpolation shenanigans without having a stroke. // The only way I could deal with Unity's interpolation shenanigans without having a stroke.