Skip to content

Commit 990e9dc

Browse files
committed
feature (Network): Fixed input States limits to be less sensitive
1 parent c55bead commit 990e9dc

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Assets/Scripts/Character/CharacterNetworkInput.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
[NetworkSettings(channel = 1, sendInterval = 0.33f)]
2121
public class CharacterNetworkInput : NetworkBehaviour {
2222

23-
private const float MAX_CLIENT_WAITING_STATES = 30; //How many states to keep on client
23+
private const float WARNING_CLIENT_WAITING_STATES = 30; //How many states to keep before warning
24+
private const float MAX_CLIENT_WAITING_STATES = 50; //How many states to keep on client
2425
private const float MAX_CLIENT_DISTANCE_WARNING = 0.25f; //Max distance between server and localy calculated position
2526
private const float MAX_SERVER_DISTANCE_SNAP = 0.15f; //Max distance between client and server calculated position before SNAPPING
2627

@@ -77,12 +78,15 @@ void FixedUpdate () {
7778
characterMovement.RunUpdate(Time.fixedDeltaTime);
7879
characterRotation.RunUpdate(Time.fixedDeltaTime);
7980
//Client: Trim commands to 25 and send commands to server
80-
Debug.Log(inputStates.Count);
81+
if (inputStates.Count > WARNING_CLIENT_WAITING_STATES)
82+
{
83+
Debug.LogWarning("[NetworkInput]: States starting pulling up, are network condition bad?");
84+
}
8185
if (inputStates.Count > MAX_CLIENT_WAITING_STATES) {
8286
Debug.LogError("Too many waiting states, starting to drop frames");
8387
}
84-
//while (inputStates.Count > MAX_CLIENT_WAITING_STATES) { inputStates.Dequeue(); }
85-
if (nextSendTime < Time.time)
88+
while (inputStates.Count > MAX_CLIENT_WAITING_STATES) { inputStates.Dequeue(); }
89+
if (isServer && isLocalPlayer || nextSendTime < Time.time)
8690
{
8791
CmdSetServerInput(inputStates.ToArray(), transform.position);
8892
nextSendTime = Time.time + 0.33f;

0 commit comments

Comments
 (0)