Search Unity

Other How do i kick players with photon

Discussion in 'Lobby' started by julianrota0, Mar 17, 2022.

Thread Status:
Not open for further replies.
  1. julianrota0

    julianrota0

    Joined:
    Feb 20, 2021
    Posts:
    1
    Im using
    1. [PunRPC]
    2. private void KickPlayer()
    3. {
    4. PhotonNetwork.LeaveRoom(); // load lobby scene, returns to master server
    5. }

    6. public void SendKickPlayer(int playerID)
    7. {
    8. PhotonPlayer player = PhotonPlayer.Find(playerID);

    9. photonView.RPC("KickPlayer",player);
    10. }
    but for some reson PhotonPlayer script doesnt exit so i have to use Player instead but when i do it says that "Find" dosent exist in the script.
    sorry for the bad english
     
  2. UnityKip

    UnityKip

    Unity Technologies

    Joined:
    Nov 15, 2021
    Posts:
    36
    Hi @julianrota0

    This question appears to be for Photon Multiplayer which is unrelated to Unity's Lobby service. Let me know if you posted here in your usage of a Unity sample and I can try to assist with any issues you may be encountering. If you need help with Photon, you will need to reach out to the developer for further assistance.

    With that said, it sounds like the error you're running into is that the PhotonPlayer script doesn't exist. I believe this may be happening because the PhotonPlayer class is deprecated in PUN2 and was renamed to just Player. However, Player is likely to be an overloaded term and you may need to specify the namespace with something like:

    Code (CSharp):
    1. public void SendKickPlayer(int playerID)
    2. {
    3.   Photon.Realtime.Player player = Photon.Realtime.Player.Find(playerID);
    4.   photonView.RPC("KickPlayer",player);
    5. }
    If this is indeed an issue with a sample found through Unity documentation, please upload the full error message you're receiving and a link to the sample for review.

    Regards,
    -Kip
     
Thread Status:
Not open for further replies.