Sync seems to work

This commit is contained in:
2026-01-03 16:07:28 +01:00
parent 68016b1d78
commit a88e4bde81
4 changed files with 229 additions and 57 deletions

View File

@@ -40,6 +40,8 @@ public class TestBall : SyncedObject
public override void SyncedUpdate()
{
SetProgress(GetProgress()); // A quick test that these methods work correctly
DeltaUp(-DownPerSecond * networkManager.Dt);
UpdateProgress();
@@ -55,7 +57,7 @@ public class TestBall : SyncedObject
private void SetProgress(float progress)
{
var currentTimestamp = NetworkManager.TimeToTimestamp(networkManager.SyncedTime);
var currentTimestamp = GetCurrentTimestamp();
loopOffset = (int)(currentTimestamp - progress * LoopTimeMs);
}
@@ -101,13 +103,13 @@ public class TestBall : SyncedObject
{
DeltaUp(UpPerPress);
Debug.Log($"({nameof(TestBall)}) Up button pressed, jumped up at {GetProgress()} to {amountUp}.");
networkManager.SendEvent((NetworkEventType)1);
}
public override void AppendSyncedData(byte[][] data, ref int index, NetworkEventType eventType)
{
if (eventType == 0)
{
Debug.Log($"({nameof(TestBall)}) Sending sync data at progress {GetProgress()} and amountUp {amountUp}.");
data[index++] = BitConverter.GetBytes(amountUp);
data[index++] = BitConverter.GetBytes(GetProgress());
}