Skip to content

Commit

Permalink
simplifying until its ready
Browse files Browse the repository at this point in the history
  • Loading branch information
dooly123 committed Jan 28, 2025
1 parent e0a1fec commit bf41904
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions Basis/Packages/com.basis.tests/BasisObjectSyncNetworking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void OnEnable()
_lastUpdateTime = Time.timeAsDouble;

StartRemoteControl();
BasisObjectSyncSystem.StartApplyRemoteData(this);
// BasisObjectSyncSystem.StartApplyRemoteData(this);
}
public void OnDisable()
{
Expand Down Expand Up @@ -119,13 +119,13 @@ private void OnOwnershipTransfer(string UniqueEntityID, ushort NetIdNewOwner, bo
}
if (IsLocalOwner == false)
{
StartRemoteControl();
// BasisObjectSyncSystem.StartApplyRemoteData(this);
// StartRemoteControl();
// BasisObjectSyncSystem.StartApplyRemoteData(this);
}
else
{
StopRemoteControl();
// BasisObjectSyncSystem.StopApplyRemoteData(this);
StopRemoteControl();
// BasisObjectSyncSystem.StopApplyRemoteData(this);
}
OwnedPickupSet();
}
Expand Down Expand Up @@ -154,13 +154,24 @@ public void OnNetworkIdAdded(string uniqueId, ushort ushortId)
OwnedPickupSet();
}
}
public float Speed = 7;
public void LateUpdate()
{
if (IsLocalOwner && HasMessageIndexAssigned)
if (IsLocalOwner)
{
double timeAsDouble = Time.timeAsDouble;
LateUpdateTime(timeAsDouble);
}
else
{
float Output = Speed * Time.deltaTime;
Current.Rotation = Quaternion.Slerp(Current.Rotation, Next.Rotation, Output);
Current.Position = Vector3.Lerp(Current.Position, Next.Position, Output);
Current.Scale = Vector3.Lerp(Current.Scale, Next.Scale, Output);

transform.SetLocalPositionAndRotation(Current.Position, Current.Rotation);
transform.localScale = Current.Scale;
}
}
public void LateUpdateTime(double DoubleTime)
{
Expand All @@ -180,9 +191,7 @@ public void OnNetworkMessageReceived(ushort PlayerID, ushort messageIndex, byte[
{
if (HasMessageIndexAssigned && messageIndex == MessageIndex)
{
Current = SerializationUtility.DeserializeValue<BasisPositionRotationScale>(buffer, DataFormat);
transform.SetLocalPositionAndRotation(Current.Position, Current.Rotation);
transform.localScale = Current.Scale;
Next = SerializationUtility.DeserializeValue<BasisPositionRotationScale>(buffer, DataFormat);
}
}
public void StartRemoteControl()
Expand Down

0 comments on commit bf41904

Please sign in to comment.