#Rhythm Game (Again) - Lerp vs Translate

1 messages · Page 1 of 1 (latest)

brisk kestrel
#

Hello! for the past year or so, I've been using a lerp system to lerp the notes to their DestroyPoint.

The NJS for the notes are 1.875, and the code is as follows:

if (JSONBeatmapLoader.instance != null)
        {
            double timeSinceInstantiated = JSONBeatmapLoader.GetAudioSourceTime() - TimeShouldBeInstantiated;
            t = (float)(timeSinceInstantiated / (JSONBeatmapLoader.instance.NJS)); //Modify "JSONBeatmapLoader.instance.NJS * 2" to change it to the time you intend to end the Lerp or the speed of the actual note,  dumbass
        }

transform.localPosition = Vector3.Lerp(Vector3.up * JSONBeatmapLoader.instance.noteCreate, Vector3.up * JSONBeatmapLoader.instance.noteDestroy, t);```

But now this poses a bit of a problem, as the value 1.875 has found through guesswork. NJS is how long the note is on screen for. 

1.875 is the exact time used, because the Hitbox position is different from the NoteDestroy Place, therefore changing NJS can screw stuff up drastically.

So, I was wondering, should I move the object without a lerp? What I was worried about is if the game lagged, the note would be out of place if I didn't use a Lerp, but I wanna know. How do I approach this problem? more stuff can be supplied if needed.
lime charm
#

Lerp is just a convenient way to write init + (dest - init) * progress - it does nothing special to mitigate lag or really even "smooth things out," it's just a nice shortcut for figuring out what "x% of the way from a to b" would be.

If you want to work with controlled speeds instead of controlled progress, Vector3.MoveTowards() can be a little more convenient.

But ultimately you could move the notes just fine without either - as long as you're factoring in time in some form or another, the motion should remain framerate independent

#

I don't really understand what "NJS" is - I would think the speed of movement/when the note should reach it's destination would be depedent on the song's beats per minute or some such? Is that what NJS is?

brisk kestrel
#

although if i change it to a controlled speed, it will be a speed, therefore way higher