Fixed the Kick to now apply properly between players

This commit is contained in:
2022-03-30 13:48:19 -05:00
parent 99fe74a8d9
commit f0e111a974

View File

@@ -168,12 +168,34 @@ public class OffenseStateManager : NetworkBehaviour
foreach(GameObject character in playableCharacters){
if(character.transform.root.GetComponent<NetworkObject>() != null && character.transform.root.GetComponent<NetworkObject>().NetworkObjectId == netObjId){
ulong kickedPlayerClientID = character.transform.root.GetComponent<NetworkObject>().OwnerClientId;
//Apply kick to other player
Debug.Log("Kicking other user");
character.GetComponent<MoveStateManager>().GetHit(direction, 20);
ClientRpcParams clientRpcParams = new ClientRpcParams
{
Send = new ClientRpcSendParams
{
TargetClientIds = new ulong[] { kickedPlayerClientID }
}
};
ApplyKickToPlayerClientRPC(kickedPlayerClientID, direction, clientRpcParams);
return;
}
}
}
[ClientRpc]
private void ApplyKickToPlayerClientRPC(ulong playerToKickID, Vector3 direction, ClientRpcParams clientRpcParams) {
GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
foreach (GameObject player in players) {
if (player.GetComponent<NetworkObject>().OwnerClientId == playerToKickID) {
player.GetComponentInChildren<MoveStateManager>().GetHit(direction, 20);
return;
}
}
}
}