Unity-Technologies / com.unity.netcode.gameobjects

Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.
MIT License
2.15k stars 435 forks source link

initial pose out of sync for child NetworkTransforms if interpolate is active #2312

Closed Daniel4144 closed 1 year ago

Daniel4144 commented 1 year ago

Description

When a child with a NetworkTransform of a Networkobject was moved before a client connects, the initial pose is not synced to the client. When it moves again after connecting, it is synced correctly. This seems to only occur, if interpolation on the NetworkTransform is on.

Reproduce Steps

  1. Create a NetworkObject with a child-object with a NetworkTransform component
  2. Assign it as PlayerPrefab
  3. Start host in instance 1 -> player spawns
  4. Move the child with the NetworkTransform
  5. Start client in instance 2 -> both player objects spawn on the client, but both are at the default position
  6. Move the child again on the host -> now the position is synced on the client

(The issue is not specific to the player object, it was just easier to test with the automatic spawning of players)

Actual Outcome

If interpolate was active on the NetworkTransform, the hosts player object appears at its default position on the client instead of the position it was moved to.

Expected Outcome

Initial position should always be synced just like for NetworkTransforms on the root of the NetworkObject

Environment

NoelStephensUnity commented 1 year ago

@Daniel4144 The following PR-2298 should resolve this issue and will be included in the up-coming update (v1.2).

If you wouldn't mind verifying that the above PR resolves your issue, then you can temporarily replace your com.unity.netcode.gameobjects manifest entry with this: "com.unity.netcode.gameobjects": "https://github.com/Unity-Technologies/com.unity.netcode.gameobjects.git?path=com.unity.netcode.gameobjects#develop",

That will use the develop branch which contains the fix that I believe is related to the issue you are describing.
Let me know if you no longer experience this issue using that branch?

Daniel4144 commented 1 year ago

Thanks for the answer and the fix @NoelStephensUnity

I checked with the develop branch as you suggested and I can confirm that this resolves the issue - the pose is synced immediately after connecting.

NoelStephensUnity commented 1 year ago

That is indeed good news to hear!
Closing this out with the confirmation that this issue is (will be) fixed in the up-coming v1.2 update.