Skip to content

Commit

Permalink
fix: OnClientEnterRoom should only fire on clients
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Langsenkamp committed May 27, 2020
1 parent cfea4d3 commit d9b7bb7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Assets/Mirror/Components/NetworkRoomPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public void Start()
room.roomSlots.Add(this);
room.RecalculateRoomPlayerIndices();

OnClientEnterRoom();
if (NetworkClient.active)
OnClientEnterRoom();
}
else
logger.LogError("RoomPlayer could not find a NetworkRoomManager. The RoomPlayer requires a NetworkRoomManager object to function. Make sure that there is one in the scene.");
Expand Down Expand Up @@ -107,13 +108,13 @@ public virtual void ReadyStateChanged(bool _, bool newReadyState)
#region Room Client Virtuals

/// <summary>
/// This is a hook that is invoked on all player objects when entering the room.
/// This is a hook that is invoked on clients for all room player objects when entering the room.
/// <para>Note: isLocalPlayer is not guaranteed to be set until OnStartLocalPlayer is called.</para>
/// </summary>
public virtual void OnClientEnterRoom() { }

/// <summary>
/// This is a hook that is invoked on all player objects when exiting the room.
/// This is a hook that is invoked on clients for all room player objects when exiting the room.
/// </summary>
public virtual void OnClientExitRoom() { }

Expand Down

0 comments on commit d9b7bb7

Please sign in to comment.