Improved network accuracy

This commit is contained in:
2026-06-11 12:25:12 +02:00
parent f0859d92ac
commit bce6b329c2
3 changed files with 30 additions and 16 deletions

View File

@@ -6048,6 +6048,10 @@ PrefabInstance:
propertyPath: serializationData.Prefab propertyPath: serializationData.Prefab
value: value:
objectReference: {fileID: 3521573303519548534, guid: 15ac0ed4c56c7784ea3ae9000fc2af1f, type: 3} objectReference: {fileID: 3521573303519548534, guid: 15ac0ed4c56c7784ea3ae9000fc2af1f, type: 3}
- target: {fileID: 3555002988650332767, guid: 15ac0ed4c56c7784ea3ae9000fc2af1f, type: 3}
propertyPath: m_LocalPosition.x
value: -0.2
objectReference: {fileID: 0}
- target: {fileID: 3559251034056489513, guid: 15ac0ed4c56c7784ea3ae9000fc2af1f, type: 3} - target: {fileID: 3559251034056489513, guid: 15ac0ed4c56c7784ea3ae9000fc2af1f, type: 3}
propertyPath: serializationData.Prefab propertyPath: serializationData.Prefab
value: value:
@@ -13506,6 +13510,10 @@ PrefabInstance:
propertyPath: serializationData.Prefab propertyPath: serializationData.Prefab
value: value:
objectReference: {fileID: 3521573303519548534, guid: 15ac0ed4c56c7784ea3ae9000fc2af1f, type: 3} objectReference: {fileID: 3521573303519548534, guid: 15ac0ed4c56c7784ea3ae9000fc2af1f, type: 3}
- target: {fileID: 3555002988650332767, guid: 15ac0ed4c56c7784ea3ae9000fc2af1f, type: 3}
propertyPath: m_LocalPosition.x
value: 0.91
objectReference: {fileID: 0}
- target: {fileID: 3559251034056489513, guid: 15ac0ed4c56c7784ea3ae9000fc2af1f, type: 3} - target: {fileID: 3559251034056489513, guid: 15ac0ed4c56c7784ea3ae9000fc2af1f, type: 3}
propertyPath: serializationData.Prefab propertyPath: serializationData.Prefab
value: value:

View File

@@ -386,25 +386,10 @@ namespace Marro.PacManUdon
// Get our target time // Get our target time
UpdateInternalTime(); UpdateInternalTime();
if (Ready)
{
if (IsOwner)
{
ProcessEventsToSend(); // Prepare events from last cycle
ProgressPingTime(); // See if we need to send a ping
}
else
{
ApplyReceivedEvents(); // See if there's events that need to be replayed
}
}
// Forwards simulated time by updateDelta until we're caught up // Forwards simulated time by updateDelta until we're caught up
while (nextUpdateTime <= internalTime) while (nextUpdateTime <= internalTime)
{ {
ProgressSyncedTime(nextUpdateTime);
PerformFixedSyncedUpdate(); PerformFixedSyncedUpdate();
nextUpdateTime = SyncedTime + updateDelta;
} }
} }
@@ -432,6 +417,26 @@ namespace Marro.PacManUdon
} }
private void PerformFixedSyncedUpdate() private void PerformFixedSyncedUpdate()
{
if (Ready)
{
if (IsOwner)
{
ProcessEventsToSend(); // Prepare events from last cycle
ProgressPingTime(); // See if we need to send a ping
}
else
{
ApplyReceivedEvents(); // See if there's events after last update that need to be replayed
}
}
ProgressSyncedTime(nextUpdateTime);
CallSyncedUpdate();
nextUpdateTime = SyncedTime + updateDelta;
}
private void CallSyncedUpdate()
{ {
IsEventUpdate = false; IsEventUpdate = false;
@@ -817,7 +822,7 @@ namespace Marro.PacManUdon
{ {
IsEventUpdate = true; IsEventUpdate = true;
while (eventsQueueIndex > 0 && nextEventTime <= internalTime) while (eventsQueueIndex > 0 && nextEventTime <= SyncedTime)
{ {
var success = ApplyEvent(eventsQueue[0]); var success = ApplyEvent(eventsQueue[0]);

View File

@@ -370,6 +370,7 @@ namespace Marro.PacManUdon
{ {
index += 8; index += 8;
base.ConsumeSyncedData(data, ref index, eventType); base.ConsumeSyncedData(data, ref index, eventType);
return true;
} }
SetTargetDirection(data.ReadVector2(ref index)); SetTargetDirection(data.ReadVector2(ref index));