Fixed Runner Spectating King Bug

- Fixed a bug where a runner would spectate the king if the host and a
  client are both runners and the client finished the race before the
  host did
This commit is contained in:
Julia Butenhoff 2022-01-19 16:36:10 -06:00
parent ade428ef8a
commit 8d81c92115
3 changed files with 4 additions and 11 deletions

View File

@ -36,8 +36,6 @@ public class Pitfall : NetworkBehaviour
// Get all players in the scene
GameObject[] playableCharacters = GameObject.FindGameObjectsWithTag("Player");
Debug.LogError("# of players: " + playableCharacters.Length);
// Find our player first
foreach (GameObject character in playableCharacters)
{
@ -50,7 +48,8 @@ public class Pitfall : NetworkBehaviour
{
character.GetComponent<NetworkObject>().Despawn(true);
} catch (SpawnStateException e) {
Debug.Log("Exception");
Debug.LogError("Spawn State Exception Exception:");
Debug.LogError(e);
return;
}
@ -113,17 +112,12 @@ public class Pitfall : NetworkBehaviour
{
if (character.GetComponent<NetworkObject>().OwnerClientId == clientId)
{
Debug.LogError("Found");
GameHandler.FindGameObjectInChildWithTag(character, "PlayerCam").GetComponent<Camera>().enabled = true;
GameHandler.FindGameObjectInChildWithTag(character, "PlayerCam").GetComponent<AudioListener>().enabled = true;
GameHandler.FindGameObjectInChildWithTag(character, "PlayerCam").GetComponent<PlayerCam>().enabled = true;
character.GetComponentInChildren<PlayerMovement>().enabled = true;
}
else
{
Debug.LogError("Failed to find");
}
}
}
}

View File

@ -39,7 +39,6 @@ public class EndCollider : NetworkBehaviour {
}
}
//todo: Check if all runners are finished
bool allFinished = true;
foreach (PlayerData pData in ServerGameNetPortal.Instance.clientData.Values) {
// Make sure we don't check the king, since the value of Finished will always be false
@ -60,7 +59,7 @@ public class EndCollider : NetworkBehaviour {
// Make sure we find the characters that aren't the one that just finished (subsequently calling the rpc)
if (character.GetComponent<NetworkObject>().OwnerClientId != serverRpcParams.Receive.SenderClientId) {
// Then grab their GUID
if (ServerGameNetPortal.Instance.clientIdToGuid.TryGetValue(serverRpcParams.Receive.SenderClientId, out string clientGuid)) {
if (ServerGameNetPortal.Instance.clientIdToGuid.TryGetValue(character.GetComponent<NetworkObject>().OwnerClientId, out string clientGuid)) {
// To verify they aren't the king
if (ServerGameNetPortal.Instance.clientData[clientGuid].IsKing != true) {
// Then call a client rpc to the finished player to enable the camera locally

View File

@ -33,7 +33,7 @@ EditorUserSettings:
value: 22424703114646680e0b0227036c6f02131b172b282d347e38271427fb
flags: 0
RecentlyUsedScenePath-9:
value: 22424703114646680e0b0227036c6f02131b172b282d347e38271427fb
value: 22424703114646680e0b0227036c78111b125507233d28242c20137df7ee3d2cfb
flags: 0
UnityRemoteCompression:
value: 337f73