diff --git a/QSB/Syncs/SyncBase.cs b/QSB/Syncs/SyncBase.cs index e8ca6cc7..a8134de3 100644 --- a/QSB/Syncs/SyncBase.cs +++ b/QSB/Syncs/SyncBase.cs @@ -17,7 +17,7 @@ namespace QSB.Syncs public abstract class SyncBase : QNetworkTransform where T : Component { - public uint PlayerId => IsPlayerObject ? NetIdentity.PlayerIdentity.NetId.Value : uint.MaxValue; + public uint PlayerId { get; private set; } = uint.MaxValue; public PlayerInfo Player => QSBPlayerManager.GetPlayer(PlayerId); private bool _baseIsReady @@ -79,10 +79,12 @@ namespace QSB.Syncs { if (IsPlayerObject) { - var lowestBound = QSBWorldSync.GetUnityObjects() - .Where(x => x.NetId.Value <= NetId.Value) - .OrderBy(x => x.NetId.Value).Last(); - NetIdentity.PlayerIdentity = lowestBound.NetIdentity; + // get player objects spawned before this object (or is this one) + // and use the most recently spawned one + PlayerId = QSBWorldSync.GetUnityObjects() + .Select(x => x.NetId.Value) + .Where(x => x <= NetId.Value) + .Max(); } DontDestroyOnLoad(gameObject); diff --git a/QuantumUNET/Components/QNetworkIdentity.cs b/QuantumUNET/Components/QNetworkIdentity.cs index a5fbb620..041d52bc 100644 --- a/QuantumUNET/Components/QNetworkIdentity.cs +++ b/QuantumUNET/Components/QNetworkIdentity.cs @@ -21,7 +21,6 @@ namespace QuantumUNET.Components public short PlayerControllerId { get; private set; } = -1; public QNetworkConnection ConnectionToServer { get; private set; } public QNetworkConnection ConnectionToClient { get; private set; } - public QNetworkIdentity PlayerIdentity { get; set; } public bool ServerOnly {