internal void SetLocalPlayer() { m_IsLocalPlayer = true; // there is an ordering issue here that originAuthority solves. OnStartAuthority should only be called if m_HasAuthority was false when this function began, // or it will be called twice for this object. But that state is lost by the time OnStartAuthority is called below, so the original value is cached // here to be checked below. bool originAuthority = m_HasAuthority; if (localPlayerAuthority) { m_HasAuthority = true; } for (int i = 0; i < m_NetworkBehaviours.Length; i++) { NetworkBehaviour comp = m_NetworkBehaviours[i]; comp.OnStartLocalPlayer(); if (localPlayerAuthority && !originAuthority) { comp.OnStartAuthority(); } } }