Timestamp is now float

This commit is contained in:
2026-01-08 19:45:22 +01:00
parent 630dc5a176
commit 14fc9ea576
5 changed files with 139 additions and 161 deletions

View File

@@ -24,15 +24,15 @@ public class TestBall : SyncedObject
private NetworkManager networkManager;
private const int LoopTimeMs = 1000;
private const float LoopTime = 1f;
private const float MaxUp = 0.7f;
private const float UpPerPress = 0.4f;
private const float DownPerSecond = 1;
private const float DownPerSecond = 1f;
private float sumOfDt;
private float amountUp = 0;
private int loopOffset = 0;
private float loopOffset = 0;
private float[] jumps;
private int jumpsIndex;
@@ -78,25 +78,25 @@ public class TestBall : SyncedObject
private void SetProgress(float progress)
{
var currentTimestamp = GetCurrentTimestamp();
loopOffset = (int)(currentTimestamp - progress * LoopTimeMs);
loopOffset = currentTimestamp - progress * LoopTime;
}
private float GetProgress()
{
var currentTimestamp = GetCurrentTimestamp();
//Debug.Log($"CurrentTimeStamp for mode {mode}: {currentTimestamp}");
return ((int)currentTimestamp - loopOffset) % LoopTimeMs / (float)LoopTimeMs; // "uint % int" is not exposed, I love working in Udon
return currentTimestamp - loopOffset % LoopTime / LoopTime;
}
private uint GetCurrentTimestamp()
private float GetCurrentTimestamp()
{
switch (mode)
{
case TestBallMode.UseNetworkTime:
return NetworkManager.TimeToTimestamp(networkManager.SyncedTime);
return networkManager.SyncedTime;
case TestBallMode.UseNetworkDt:
case TestBallMode.UseUnityDt:
return NetworkManager.TimeToTimestamp(sumOfDt);
return sumOfDt;
default:
Debug.LogError($"({nameof(TestBall)}) Unknown mode {mode}!");
return 0;