- Home /
Is Start() always after OnStaretLocalPlayer() and isLocalPlayer
In testing I am finding that Start() is always called after OnStartLocalplayer (and after isLocalPlayer is set).
This is working fine and I have seen other example code (not official examples) where isLocalPlayer is referenced in Start().
But is this safe? Will it always be the case that isLocalPlayer is set in Start()?
Since I can find no documentation on this I assume it is not guaranteed as isLocalPlayer is only set after receipt of an Owner message from the server.
Can anyone that knows give a definitive answer to this?
I don't know. I would suggest creating a thread about the calling order being undocumented in the documentation forums, that helps getting the stuff documented. It's here:
Start() occurs after Awake() that is all.
OnStartLocalplayer occurs whenever you setup the network and declare the local player. So the order of operations is entirely in your control. Though Start() occurs before OnEnable and before any Updatre() functions. So it is usually a best practice to connect to multiplayer via a an interaction.
That's not quite right. OnEnable is fired directly after Awake. According to the following page, Start is always the last call except for on the Host where it's the second last before OnSetLocalVisibility.
https://docs.unity3d.com/$$anonymous$$anual/NetworkBehaviourCallbacks.html
How they guarantee that, I have no idea. If your Internet connection is really f*** up, you might get a Start call before UNET manages to do all its calls, but that's an assumption I can't prove.
Your answer
Follow this Question
Related Questions
Do I need a player prefab spawn to use Unity's HLAPI System?, 1 Answer
network player only flip on LAN Host not in Lan Client 1 Answer
Unity networking solution (PUN or Bolt) 0 Answers
Unity multiplayer solutions: Photon, Unity Networking - what else and in what way is good? 0 Answers
Unity Multiplayer Design. Is it complicated to implement and learn? 1 Answer