Skip to content

Commit

Permalink
feat(ServerObjectManager): adding ReplaceCharacter method that takes …
Browse files Browse the repository at this point in the history
…Identity and hash
  • Loading branch information
James-Frowen committed Nov 7, 2021
1 parent 0ddfdb8 commit 4320c05
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions Assets/Mirage/Runtime/ServerObjectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,22 @@ void StartedHost()
public void ReplaceCharacter(INetworkPlayer player, GameObject character, int prefabHash, bool keepAuthority = false)
{
NetworkIdentity identity = character.GetNetworkIdentity();
identity.PrefabHash = prefabHash;
ReplaceCharacter(player, identity, keepAuthority);
ReplaceCharacter(player, identity, prefabHash, keepAuthority);
}

/// <summary>
/// This replaces the player object for a connection with a different player object. The old player object is not destroyed.
/// <para>If a connection already has a player object, this can be used to replace that object with a different player object. This does NOT change the ready state of the connection, so it can safely be used while changing scenes.</para>
/// </summary>
/// <param name="player">Connection which is adding the player.</param>
/// <param name="character">Player object spawned for the player.</param>
/// <param name="prefabHash"></param>
/// <param name="keepAuthority">Does the previous player remain attached to this connection?</param>
/// <returns></returns>
public void ReplaceCharacter(INetworkPlayer player, NetworkIdentity character, int prefabHash, bool keepAuthority = false)
{
character.PrefabHash = prefabHash;
ReplaceCharacter(player, character, keepAuthority);
}

/// <summary>
Expand Down

0 comments on commit 4320c05

Please sign in to comment.