From 710ef8d6b487dd7314cc09e97d9db2439ec1661d Mon Sep 17 00:00:00 2001 From: excitedneon Date: Thu, 11 May 2017 22:17:24 +0300 Subject: [PATCH 1/2] Remove debug print --- Assets/Scripts/Util/TextTextureRenderer.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/Assets/Scripts/Util/TextTextureRenderer.cs b/Assets/Scripts/Util/TextTextureRenderer.cs index ed27f8e..9350c94 100644 --- a/Assets/Scripts/Util/TextTextureRenderer.cs +++ b/Assets/Scripts/Util/TextTextureRenderer.cs @@ -66,9 +66,6 @@ namespace Cyber.Util { string Hash = CreateHash(text); if (forceRender || !Cache.ContainsKey(Hash)) { Cache[Hash] = Singleton.RenderText(text); - Term.Println("Created a new texture for:"); - Term.Println(Hash); - Term.Println("===="); } return Cache[Hash]; } From fa6109e9acce04d13f7ad76485c58e5e44605c1b Mon Sep 17 00:00:00 2001 From: excitedneon Date: Thu, 11 May 2017 22:19:37 +0300 Subject: [PATCH 2/2] Sync and lerp rotation from server on the client side --- .../Scripts/Entities/SyncBases/Character.cs | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Assets/Scripts/Entities/SyncBases/Character.cs b/Assets/Scripts/Entities/SyncBases/Character.cs index 0339dc4..1d090f4 100644 --- a/Assets/Scripts/Entities/SyncBases/Character.cs +++ b/Assets/Scripts/Entities/SyncBases/Character.cs @@ -33,6 +33,8 @@ namespace Cyber.Entities.SyncBases { private Vector3 MovementDirection = new Vector3(); private Vector3 ServerPosition = new Vector3(); private bool ServerPositionShouldLerpSync = false; + private Vector3 ServerRotation = new Vector3(); + private bool ServerRotationShouldLerpSync = false; /// /// Moves the character in the given direction. @@ -124,7 +126,7 @@ namespace Cyber.Entities.SyncBases { public override void Deserialize(NetworkReader reader) { ServerPosition = reader.ReadVector3(); Vector3 ServerMovementDirection = reader.ReadVector3(); - Vector3 ServerRotation = reader.ReadVector3(); + ServerRotation = reader.ReadVector3(); float Drift = (ServerPosition - GetPosition()).magnitude; @@ -135,12 +137,10 @@ namespace Cyber.Entities.SyncBases { MovementDirection = ServerMovementDirection; } - // Update position more often (with lerping) if this is not the local player - if (Drift < 0.1) { - ServerPositionShouldLerpSync = false; - } else if (!LocalCharacter.Equals(this)) { - ServerPositionShouldLerpSync = true; - } + // Update position and rotation more often (with lerping) + // if this is not the local player + ServerRotationShouldLerpSync = !LocalCharacter.Equals(this); + ServerPositionShouldLerpSync = !LocalCharacter.Equals(this) && Drift > 0.1; } /// @@ -157,6 +157,13 @@ namespace Cyber.Entities.SyncBases { if (ServerPositionShouldLerpSync) { SetPosition(Vector3.Lerp(GetPosition(), ServerPosition, 10f * Time.deltaTime)); } + if (ServerRotationShouldLerpSync) { + Quaternion ServerRot = Quaternion.Euler(ServerRotation); + Quaternion LocalRot = Quaternion.Euler(GetRotation()); + Vector3 NewRot = Quaternion.Lerp(LocalRot, ServerRot, + 10f * Time.deltaTime).eulerAngles; + SetRotation(NewRot); + } } private void FixedUpdate() {