Closed ooonush closed 3 months ago
What works for me is this despawn method:
private uint _tickSpawned;
private NetworkObject _no;
public override void OnStartClient()
{
if (IsHostInitialized)
{
_no = NetworkManager.GetPooledInstantiated(_prefab.NetworkObject, true);
Spawn(_no);
_tickSpawned = TimeManager.Tick;
}
}
private void TimeManager_OnTick()
{
if (_no && TimeManager.Tick > _tickSpawned + 2)
{
Despawn(_no);
_no = null;
}
}
That is, I have to do a check for TimeManager.Tick > _tickSpawned + 2.
For clients-only
the check TimeManager.Tick > _tickSpawned
works. But on the client-host
I have to check TimeManager.Tick > _tickSpawned + 2
, which is not very elegant.
I'm fairly certain your desired setup should work without any changes. There's even code specific to sending pending SyncType data through on despawn for this exact scenario.
I'll make this is a bug today and take a look, most likely something small.
On Thu, Jun 6, 2024, 5:07 AM Alven @.***> wrote:
For clients-only the check TimeManager.Tick > _tickSpawned works. But on the client-host I have to check TimeManager.Tick > _tickSpawned + 2, which is not very elegant.
— Reply to this email directly, view it on GitHub https://github.com/FirstGearGames/FishNet/issues/692#issuecomment-2151785262, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGPJC3RIGMIPJTF4KJN6QVTZGARGNAVCNFSM6AAAAABI4HYCVOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJRG44DKMRWGI . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Do not have time to get this into 4.3.6 but making it high priority for 4.3.7
Priority updated to after delta serializers for prediction. The serializers are close to being finished so I'd like to finish them up first.
Resolved in 4.4.0
General Unity version: 6000.0.3 Fish-Networking version: 4.3.5
Description SyncType does not send changes to client when NetworkObject is despawned on the same tick it's spawned.
Replication
Place the NetworkObject with the TestSpawner component on the scene:
Create a NetworkObject prefab with a TestNetworkBehaviour component:
Expected behavior
On client started SyncType should be 10, not 0. Since OnStartClient is being called, the SyncTypes should also be synchronized. This is a problem for me when the projectile is despawned on the same tick it`s spawned.
Screenshots