From 136c1d2b302767a07fad892f7286c5dd771d4b5f Mon Sep 17 00:00:00 2001 From: MrGadget <9826063+MrGadget1024@users.noreply.github.com> Date: Fri, 9 Feb 2024 03:47:23 -0500 Subject: [PATCH] feat(NetworkRigidbody): Default Sync Direction = Client To Server (#3764) - This is done in Reset so Network Behaviour isn't effected. - This will not change components already in place on objects / prefabs unless user manually chooses Reset in the inspector. --- .../Mirror/Components/Experimental/NetworkLerpRigidbody.cs | 7 +++++++ Assets/Mirror/Components/Experimental/NetworkRigidbody.cs | 7 +++++++ .../Mirror/Components/Experimental/NetworkRigidbody2D.cs | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/Assets/Mirror/Components/Experimental/NetworkLerpRigidbody.cs b/Assets/Mirror/Components/Experimental/NetworkLerpRigidbody.cs index 1b19ab729..adca7cbb1 100644 --- a/Assets/Mirror/Components/Experimental/NetworkLerpRigidbody.cs +++ b/Assets/Mirror/Components/Experimental/NetworkLerpRigidbody.cs @@ -38,8 +38,15 @@ public class NetworkLerpRigidbody : NetworkBehaviour protected override void OnValidate() { base.OnValidate(); + Reset(); + } + + public virtual void Reset() + { if (target == null) target = GetComponent(); + + syncDirection = SyncDirection.ClientToServer; } void Update() diff --git a/Assets/Mirror/Components/Experimental/NetworkRigidbody.cs b/Assets/Mirror/Components/Experimental/NetworkRigidbody.cs index 0c2498d7b..aa204ad33 100644 --- a/Assets/Mirror/Components/Experimental/NetworkRigidbody.cs +++ b/Assets/Mirror/Components/Experimental/NetworkRigidbody.cs @@ -42,8 +42,15 @@ public class NetworkRigidbody : NetworkBehaviour protected override void OnValidate() { base.OnValidate(); + Reset(); + } + + public virtual void Reset() + { if (target == null) target = GetComponent(); + + syncDirection = SyncDirection.ClientToServer; } #region Sync vars diff --git a/Assets/Mirror/Components/Experimental/NetworkRigidbody2D.cs b/Assets/Mirror/Components/Experimental/NetworkRigidbody2D.cs index e3bdd2992..79c07712e 100644 --- a/Assets/Mirror/Components/Experimental/NetworkRigidbody2D.cs +++ b/Assets/Mirror/Components/Experimental/NetworkRigidbody2D.cs @@ -40,8 +40,15 @@ public class NetworkRigidbody2D : NetworkBehaviour protected override void OnValidate() { base.OnValidate(); + Reset(); + } + + public virtual void Reset() + { if (target == null) target = GetComponent(); + + syncDirection = SyncDirection.ClientToServer; } #region Sync vars