-
-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LocalTick breaks "only increment" promise when connecting the host client #559
Comments
Localtick should only change when a tick iterates or when the socket is
reset. Every OnTick should be incremental. This does sound a bit weird.
…On Sat, Nov 25, 2023, 3:34 AM Freddie Wang ***@***.***> wrote:
*General*
Unity version: 2022.3.8f
Fish-Networking version: 4.0.3 & 3.11.10
*Description*
When host client connects, both LocalTick and Tick value (since they are
the same value when server is running) decreases.
Although I believe "Tick" shouldn't decrease either in server. LocalTick
did promise that in the XML doc.
*Replication*
1. Attach the following script to an empty scene with the example
NetworkManager prefab
2. Run the scene
3. Click "Server"
4. Click "Client"
using FishNet;
using FishNet.Transporting;
using UnityEngine;
public class TickCheck : MonoBehaviour
{
private long _lastTick = -1;
private bool _initialized;
private void Update()
{
if (!_initialized)
{
var serverManager = InstanceFinder.ServerManager;
if (serverManager)
{
serverManager.OnServerConnectionState += OnServerConnectionState;
_initialized = true;
}
}
}
private void OnServerConnectionState(ServerConnectionStateArgs args)
{
switch (args.ConnectionState)
{
case LocalConnectionState.Started:
InstanceFinder.TimeManager.OnTick += OnTick;
break;
case LocalConnectionState.Stopping:
InstanceFinder.TimeManager.OnTick -= OnTick;
_lastTick = -1;
break;
}
}
private void OnTick()
{
if (_lastTick == -1)
{
_lastTick = InstanceFinder.TimeManager.LocalTick;
return;
}
if (InstanceFinder.TimeManager.LocalTick - _lastTick != 1)
{
var expectedTick = _lastTick + 1;
Debug.LogError($"Expecting tick: {expectedTick}, Unexpected tick: {InstanceFinder.TimeManager.LocalTick}");
}
_lastTick = InstanceFinder.TimeManager.LocalTick;
}
}
*Expected behavior*
The LocalTick (or Tick in server) shouldn't decrease or stay the same
during two different OnTick/OnPreTick/OnPostTick calls
—
Reply to this email directly, view it on GitHub
<#559>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGPJC3RQ5HIM666ROVX5NXDYGGUP3AVCNFSM6AAAAAA7Z6GE5CVHI2DSMVQWIX3LMV43ASLTON2WKOZSGAYTANJTGA3TANY>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
After reviewing your example more thoroughly(on desktop) I see that you are disconnecting a socket. The tick is supposed to reset when the socket closes. When clientHost the client uses the servers tick since it is the server, so tick will reset when clientOnly or when server socket changes. In other words, seems to be working properly. |
Is connecting a client as host disconnecting the socket? |
No, that should not reset Tick. If that's happening it is indeed a bug. |
The testing code listening LocalConnectionState is just to reset the test when Server stops. The reproduceable steps does not involve stopping the server. Click Server -> Click Client -> Mismatched tick |
I was able to reproduce. Thanks! |
Here's the line that needs correction... Inside //Only do this if not also server.
if (!networkManager.IsServer)
networkManager.TimeManager.Tick = networkManager.TimeManager.LastPacketTick; |
- Fixed clientHost setting Tick value overwriting servers value. (#559)(#560) - Fixed NetworkTransform sending repeatedly under certain conditions, bug introduced in 3.11.11. - Fixed key already exist error when multiple classes with SyncTypes inherited the same NetworkBehaviour. - Improved logging message when a RPC or SyncType index has already been registered. - Changed Release Mode and Development Mode to Stable and Beta. - Changed RigidbodyPauser parenting fix is no longer in Beta. - Fixed Version 3 to Version 4 SyncType validator causing editor error for abstract NetworkBehaviours while on IL2CPP.
General
Unity version: 2022.3.8f
Fish-Networking version: 4.0.3 & 3.11.10
Description
When host client connects, both LocalTick and Tick value (since they are the same value when server is running) decreases.
Although I believe "Tick" shouldn't decrease either in server, LocalTick did promise that in the XML doc.
Replication
Expected behavior
The LocalTick (or Tick in server) shouldn't decrease or stay the same during two different OnTick/OnPreTick/OnPostTick calls
The text was updated successfully, but these errors were encountered: