Sync seems to work
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user