diff --git a/Assets/Scripts/Entities/Character.cs b/Assets/Scripts/Entities/Character.cs
index fd2b69f..6ebb96a 100644
--- a/Assets/Scripts/Entities/Character.cs
+++ b/Assets/Scripts/Entities/Character.cs
@@ -25,6 +25,8 @@ namespace Cyber.Entities {
public Transform Head;
private Vector3 MovementDirection = new Vector3();
+ private Vector3 ServerPosition = new Vector3();
+ private bool SyncToServerPosition = false;
///
/// Moves the character in the given direction.
@@ -90,8 +92,13 @@ namespace Cyber.Entities {
///
///
public override void Deserialize(NetworkReader reader) {
- transform.position = reader.ReadVector3();
- Move(reader.ReadVector3());
+ ServerPosition = reader.ReadVector3();
+ float Drift = (ServerPosition - transform.position).magnitude;
+ if (Drift > 1) {
+ SyncToServerPosition = true;
+ } else if (Drift < 0.01) {
+ SyncToServerPosition = false;
+ }
Vector3 rot = reader.ReadVector3();
}
@@ -101,10 +108,19 @@ namespace Cyber.Entities {
///
public override void Serialize(NetworkWriter writer) {
writer.Write(transform.position);
- writer.Write(MovementDirection);
writer.Write(GetRotation());
}
+ private void Update() {
+ if (SyncToServerPosition) {
+ // LERP version
+ //transform.position = Vector3.Lerp(transform.position, ServerPosition, 50f * Time.deltaTime);
+ // Non-LERP version
+ transform.position = ServerPosition;
+ SyncToServerPosition = false;
+ }
+ }
+
private void FixedUpdate() {
CharacterController.Move(MovementDirection * MovementSpeed * Time.fixedDeltaTime);
}
diff --git a/ProjectSettings/UnityConnectSettings.asset b/ProjectSettings/UnityConnectSettings.asset
index ec1ab29..613cb2f 100644
--- a/ProjectSettings/UnityConnectSettings.asset
+++ b/ProjectSettings/UnityConnectSettings.asset
@@ -23,9 +23,9 @@ UnityConnectSettings:
m_TestConfigUrl:
UnityAdsSettings:
m_Enabled: 0
- m_InitializeOnStartup: 1
+ m_InitializeOnStartup: 0
m_TestMode: 0
- m_EnabledPlatforms: 4294967295
+ m_EnabledPlatforms: 4294964991
m_IosGameId:
m_AndroidGameId:
PerformanceReportingSettings: