feat(NetworkTransform): Default Sync Direction = Client To Server (#3741)

* feat(NetworkTransform): Default Sync Direction = Client To Server
- This is done in Reset so Network Behaviour isn't effected.
- This will not change NT components already in place on objects / prefabs unless user manually chooses Reset in the inspector.

* Update Assets/Mirror/Components/NetworkTransform/NetworkTransformBase.cs

---------

Co-authored-by: mischa <16416509+miwarnec@users.noreply.github.com>
This commit is contained in:
MrGadget 2024-01-20 04:47:41 -05:00 committed by GitHub
parent e10ab75bf5
commit 258a84c066
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 0 deletions

View File

@ -378,6 +378,8 @@ public virtual void ResetState()
public virtual void Reset()
{
ResetState();
// default to ClientToServer so this works immediately for users
syncDirection = SyncDirection.ClientToServer;
}
protected virtual void OnEnable()

View File

@ -314,6 +314,9 @@ public void OnServerToClientSync_WithClientAuthority_Nullables_Uses_Last()
component.netIdentity.isClient = true;
component.netIdentity.isLocalPlayer = true;
// client authority has to be disabled
component.syncDirection = SyncDirection.ServerToClient;
// call OnClientToServerSync with authority and nullable types
// to make sure it uses the last valid position then.
component.OnServerToClientSync(new Vector3?(), new Quaternion?(), new Vector3?());