From d712cd03039aea92083b1be97197f6272b2296b5 Mon Sep 17 00:00:00 2001 From: vis2k Date: Mon, 30 Dec 2019 11:00:20 +0100 Subject: [PATCH] fix: NetworkTransform clientAuthority works again via clientAuthority option that is configurable in inspector. this had to be fixed after we removed local authority. --- Assets/Mirror/Components/NetworkTransformBase.cs | 10 ++++++++-- Assets/Mirror/Examples/Pong/Prefabs/Racket.prefab | 1 + Assets/Mirror/Examples/Room/Prefabs/GamePlayer.prefab | 10 +++++----- Assets/Mirror/Examples/Tanks/Prefabs/Tank.prefab | 5 +++-- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Assets/Mirror/Components/NetworkTransformBase.cs b/Assets/Mirror/Components/NetworkTransformBase.cs index 798c1cab0d0..7a3e5e8e44a 100644 --- a/Assets/Mirror/Components/NetworkTransformBase.cs +++ b/Assets/Mirror/Components/NetworkTransformBase.cs @@ -32,6 +32,12 @@ public abstract class NetworkTransformBase : NetworkBehaviour [SerializeField] Compression compressRotation = Compression.Much; public enum Compression { None, Much, Lots, NoRotation }; // easily understandable and funny + [Tooltip("Set to true if moves come from owner client, set to false if moves always come from server")] + public bool clientAuthority; + + // is this a local player with authority over his own transform? + bool isLocalPlayerWithAuthority => isLocalPlayer && clientAuthority; + // server Vector3 lastPosition; Quaternion lastRotation; @@ -364,7 +370,7 @@ void Update() { // send to server if we have local authority (and aren't the server) // -> only if connectionToServer has been initialized yet too - if (!isServer && hasAuthority) + if (!isServer && isLocalPlayerWithAuthority) { // check only each 'syncInterval' if (Time.time - lastClientSendTime >= syncInterval) @@ -386,7 +392,7 @@ void Update() // apply interpolation on client for all players // unless this client has authority over the object. could be // himself or another object that he was assigned authority over - if (!hasAuthority) + if (!isLocalPlayerWithAuthority) { // received one yet? (initialized?) if (goal != null) diff --git a/Assets/Mirror/Examples/Pong/Prefabs/Racket.prefab b/Assets/Mirror/Examples/Pong/Prefabs/Racket.prefab index 3bb7a14930c..cdd4e0fd17c 100644 --- a/Assets/Mirror/Examples/Pong/Prefabs/Racket.prefab +++ b/Assets/Mirror/Examples/Pong/Prefabs/Racket.prefab @@ -177,3 +177,4 @@ MonoBehaviour: syncMode: 0 syncInterval: 0 compressRotation: 1 + clientAuthority: 1 diff --git a/Assets/Mirror/Examples/Room/Prefabs/GamePlayer.prefab b/Assets/Mirror/Examples/Room/Prefabs/GamePlayer.prefab index 06a955afba8..941c771cfbb 100644 --- a/Assets/Mirror/Examples/Room/Prefabs/GamePlayer.prefab +++ b/Assets/Mirror/Examples/Room/Prefabs/GamePlayer.prefab @@ -195,16 +195,15 @@ MonoBehaviour: syncInterval: 0 characterController: {fileID: 143011667059871024} moveSpeed: 8 - turnSpeedAccel: 5 - turnSpeedDecel: 5 + turnSensitivity: 5 maxTurnSpeed: 150 - jumpSpeed: 0 - jumpFactor: 0.025 horizontal: 0 vertical: 0 turn: 0 + jumpSpeed: 0 isGrounded: 1 isFalling: 0 + velocity: {x: 0, y: 0, z: 0} --- !u!114 &6261579163786439309 MonoBehaviour: m_ObjectHideFlags: 0 @@ -251,7 +250,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: serverOnly: 0 - m_AssetId: + m_AssetId: 21daf89214c6ee443ad6875b73083c60 m_SceneId: 0 --- !u!114 &114265392388239132 MonoBehaviour: @@ -268,3 +267,4 @@ MonoBehaviour: syncMode: 0 syncInterval: 0 compressRotation: 1 + clientAuthority: 1 diff --git a/Assets/Mirror/Examples/Tanks/Prefabs/Tank.prefab b/Assets/Mirror/Examples/Tanks/Prefabs/Tank.prefab index 94855c1cb9d..4b317f656d5 100644 --- a/Assets/Mirror/Examples/Tanks/Prefabs/Tank.prefab +++ b/Assets/Mirror/Examples/Tanks/Prefabs/Tank.prefab @@ -52,8 +52,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: serverOnly: 0 - m_AssetId: - m_SceneId: 4003200786 + m_AssetId: 6f43bf5488a7443d19ab2a83c6b91f35 + m_SceneId: 0 --- !u!95 &2240606817507776182 Animator: serializedVersion: 3 @@ -88,6 +88,7 @@ MonoBehaviour: syncMode: 0 syncInterval: 0.1 compressRotation: 1 + clientAuthority: 1 --- !u!195 &6900008319038825817 NavMeshAgent: m_ObjectHideFlags: 0