Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion com.unity.multiplayer.mlapi/Editor/NetworkManagerEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class NetworkManagerEditor : Editor
private SerializedProperty m_AllowRuntimeSceneChangesProperty;
private SerializedProperty m_NetworkTransportProperty;
private SerializedProperty m_ReceiveTickrateProperty;
private SerializedProperty m_NetworkTickIntervalSecProperty;
private SerializedProperty m_MaxReceiveEventsPerTickRateProperty;
private SerializedProperty m_EventTickrateProperty;
private SerializedProperty m_MaxObjectUpdatesPerTickProperty;
Expand Down Expand Up @@ -100,6 +101,7 @@ private void Init()
m_AllowRuntimeSceneChangesProperty = m_NetworkConfigProperty.FindPropertyRelative("AllowRuntimeSceneChanges");
m_NetworkTransportProperty = m_NetworkConfigProperty.FindPropertyRelative("NetworkTransport");
m_ReceiveTickrateProperty = m_NetworkConfigProperty.FindPropertyRelative("ReceiveTickrate");
m_NetworkTickIntervalSecProperty = m_NetworkConfigProperty.FindPropertyRelative("NetworkTickIntervalSec");
m_MaxReceiveEventsPerTickRateProperty = m_NetworkConfigProperty.FindPropertyRelative("MaxReceiveEventsPerTickRate");
m_EventTickrateProperty = m_NetworkConfigProperty.FindPropertyRelative("EventTickrate");
m_ClientConnectionBufferTimeoutProperty = m_NetworkConfigProperty.FindPropertyRelative("ClientConnectionBufferTimeout");
Expand Down Expand Up @@ -137,6 +139,7 @@ private void CheckNullProperties()
m_AllowRuntimeSceneChangesProperty = m_NetworkConfigProperty.FindPropertyRelative("AllowRuntimeSceneChanges");
m_NetworkTransportProperty = m_NetworkConfigProperty.FindPropertyRelative("NetworkTransport");
m_ReceiveTickrateProperty = m_NetworkConfigProperty.FindPropertyRelative("ReceiveTickrate");
m_NetworkTickIntervalSecProperty = m_NetworkConfigProperty.FindPropertyRelative("NetworkTickIntervalSec");
m_MaxReceiveEventsPerTickRateProperty = m_NetworkConfigProperty.FindPropertyRelative("MaxReceiveEventsPerTickRate");
m_EventTickrateProperty = m_NetworkConfigProperty.FindPropertyRelative("EventTickrate");
m_ClientConnectionBufferTimeoutProperty = m_NetworkConfigProperty.FindPropertyRelative("ClientConnectionBufferTimeout");
Expand Down Expand Up @@ -283,6 +286,7 @@ public override void OnInspectorGUI()

EditorGUILayout.LabelField("Performance", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(m_ReceiveTickrateProperty);
EditorGUILayout.PropertyField(m_NetworkTickIntervalSecProperty);
EditorGUILayout.PropertyField(m_MaxReceiveEventsPerTickRateProperty);
EditorGUILayout.PropertyField(m_EventTickrateProperty);
EditorGUILayout.PropertyField(m_EnableNetworkVariableProperty);
Expand Down Expand Up @@ -407,4 +411,4 @@ public override void OnInspectorGUI()
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ public class NetworkConfig
[Tooltip("The amount of times per second the receive queue is emptied from pending incoming messages")]
public int ReceiveTickrate = 64;

/// <summary>
/// Duration in seconds between network ticks.
/// </summary>
[Tooltip("Duration in seconds between network ticks")]
public float NetworkTickIntervalSec = 0.050f;
Comment thread
jeffreyrainy marked this conversation as resolved.

/// <summary>
/// The max amount of messages to process per ReceiveTickrate. This is to prevent flooding.
/// </summary>
Expand Down Expand Up @@ -351,4 +357,4 @@ public bool CompareConfig(ulong hash)
return hash == GetConfig();
}
}
}
}
4 changes: 2 additions & 2 deletions com.unity.multiplayer.mlapi/Runtime/Core/NetworkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ private void Init(bool server)
NetworkTickSystem = null;
}

NetworkTickSystem = new NetworkTickSystem();
NetworkTickSystem = new NetworkTickSystem(NetworkConfig.NetworkTickIntervalSec);
Comment thread
jeffreyrainy marked this conversation as resolved.

//This should never happen, but in the event that it does there should be (at a minimum) a unity error logged.
if (RpcQueueContainer != null)
Expand Down Expand Up @@ -1487,4 +1487,4 @@ internal void HandleApproval(ulong clientId, bool createPlayerObject, ulong? pla
}
}
}
}
}
4 changes: 2 additions & 2 deletions com.unity.multiplayer.mlapi/Runtime/Core/NetworkTickSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace MLAPI

public class NetworkTickSystem : INetworkUpdateSystem, IDisposable
{
private const float k_DefaultTickIntervalSec = 1 / 60f; // Defaults to 60 ticks second
private const float k_DefaultTickIntervalSec = 0.05f; // Defaults to 20 ticks second
private readonly float m_TickIntervalSec; // Duration of a tick in seconds
private int m_NetworkTickCount; // How many network ticks have passed?

Expand Down Expand Up @@ -80,4 +80,4 @@ public void NetworkUpdate(NetworkUpdateStage updateStage)
}
}
}
}
}
1 change: 1 addition & 0 deletions testproject/Assets/Scenes/SampleScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ MonoBehaviour:
id: 0
CreatePlayerPrefab: 1
ReceiveTickrate: 64
NetworkTickIntervalSec: 0.05
MaxReceiveEventsPerTickRate: 500
EventTickrate: 64
ClientConnectionBufferTimeout: 10
Expand Down