Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MiniGamesPlayer : NetworkBehaviour
- {
- public MiniGamesLevel MiniGames => MiniGamesLevel.Instance;
- public bool IsLocal => MiniGames.Players.Local == this;
- public bool IsRemote => MiniGames.Players.Remote == this;
- protected override void OnNetworkPostSpawn()
- {
- base.OnNetworkPostSpawn();
- Debug.Log($"Mini Games Player {(NetworkObject.IsLocalPlayer ? "Local" : "Remote")} Spawned, Scene: {gameObject.scene}");
- //This is the line that will throw a null reference exception on any late-joining client as the "MiniGamesLevel.Instance" is still not set because the scene is not yet loaded
- MiniGames.Players.Assign(this, NetworkObject.IsLocalPlayer);
- if (IsLocal)
- name = $"Player [Local]";
- else
- name = $"Player [Remote]";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement