Unity-Technologies / Unity-Technologies/com.unity.netcode.gameobjects

NetworkTransform misses sync when GameObject is re-enabled; add option for automatic reassertion

Offen
#3,435 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

priority:low stat:awaiting-response stat:imported type:feature type:feature-2.x type:support
Vorherrschende Sprache
C#
Sterne
2.3k
Forks
461
Ø Merge
3 T. 16 Std.
Gemergte PRs (30 T.)
20

Beschreibung

Description
When using NetworkTransform in server-authoritative mode, if a NetworkObject is deactivated on clients (e.g. via SetActive(false) or scene streaming), any transform changes (e.g. via Teleport) made while it's inactive are not propagated to the client once it's re-enabled. This results in position mismatches, where the client sees the object at its old position while the server has already moved it.

There is no warning, and the desync is silent unless manually corrected.

Reproduction Steps
Spawn a server-authoritative NetworkObject with a NetworkTransform

Deactivate the object on all clients (via RPC or reparenting in a disabled object)

On the server, call Teleport(...) to move the object

Reactivate the object after a short delay

Observe: the client does not reflect the new position

Expected Behavior
Clients should receive the latest authoritative position of the object when it becomes active again.

Workarounds
Currently, we must:

Reapply Teleport() after reactivating the object, or

Use a coroutine to delay the teleport until the object is re-enabled, or

Use custom NetworkVariable logic or whatever boiler plate works instead of NetworkTransform

Suggested Fixes
Add a forceResyncOnEnable bool on NetworkTransform

Internally store the last known transform state, and resend it on reactivation

Or provide an OnNetworkObjectReenabled callback for developers to manually reassert state

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit der serverautoritativen Behandlung von Teleport durch NetworkTransform, während das NetworkObject inaktiv ist, und reproduziere anschließend die beschriebene Sequenz aus Deaktivieren, Verschieben und erneuter Aktivierung. Ermittle, wie die letzte autoritative Transformation bei der Reaktivierung erneut durchgesetzt werden kann, und verifiziere, dass der Client die aktualisierte Position erhält, ohne einen zweiten Teleport-Aufruf zu benötigen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
csharp, unity
Bereich
networking
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.