|
20 | 20 | [NetworkSettings(channel = 1, sendInterval = 0.33f)]
|
21 | 21 | public class CharacterNetworkInput : NetworkBehaviour {
|
22 | 22 |
|
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 |
24 | 25 | private const float MAX_CLIENT_DISTANCE_WARNING = 0.25f; //Max distance between server and localy calculated position
|
25 | 26 | private const float MAX_SERVER_DISTANCE_SNAP = 0.15f; //Max distance between client and server calculated position before SNAPPING
|
26 | 27 |
|
@@ -77,12 +78,15 @@ void FixedUpdate () {
|
77 | 78 | characterMovement.RunUpdate(Time.fixedDeltaTime);
|
78 | 79 | characterRotation.RunUpdate(Time.fixedDeltaTime);
|
79 | 80 | //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 | + } |
81 | 85 | if (inputStates.Count > MAX_CLIENT_WAITING_STATES) {
|
82 | 86 | Debug.LogError("Too many waiting states, starting to drop frames");
|
83 | 87 | }
|
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) |
86 | 90 | {
|
87 | 91 | CmdSetServerInput(inputStates.ToArray(), transform.position);
|
88 | 92 | nextSendTime = Time.time + 0.33f;
|
|
0 commit comments