Skip to content

Commit

Permalink
fix: NetworkTransform clientAuthority works again via clientAuthority…
Browse files Browse the repository at this point in the history
… option that is configurable in inspector. this had to be fixed after we removed local authority.
  • Loading branch information
miwarnec committed Dec 30, 2019
1 parent 952855e commit d712cd0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
10 changes: 8 additions & 2 deletions Assets/Mirror/Components/NetworkTransformBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions Assets/Mirror/Examples/Pong/Prefabs/Racket.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,4 @@ MonoBehaviour:
syncMode: 0
syncInterval: 0
compressRotation: 1
clientAuthority: 1
10 changes: 5 additions & 5 deletions Assets/Mirror/Examples/Room/Prefabs/GamePlayer.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -251,7 +250,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
serverOnly: 0
m_AssetId:
m_AssetId: 21daf89214c6ee443ad6875b73083c60
m_SceneId: 0
--- !u!114 &114265392388239132
MonoBehaviour:
Expand All @@ -268,3 +267,4 @@ MonoBehaviour:
syncMode: 0
syncInterval: 0
compressRotation: 1
clientAuthority: 1
5 changes: 3 additions & 2 deletions Assets/Mirror/Examples/Tanks/Prefabs/Tank.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -88,6 +88,7 @@ MonoBehaviour:
syncMode: 0
syncInterval: 0.1
compressRotation: 1
clientAuthority: 1
--- !u!195 &6900008319038825817
NavMeshAgent:
m_ObjectHideFlags: 0
Expand Down

0 comments on commit d712cd0

Please sign in to comment.