Search Unity

Third Party Error cs0115:CustomNetworkManager.OnServerAddPlayer(NetworkConnection)': no suitable method found...

Discussion in 'Multiplayer' started by Gyula84, Apr 6, 2022.

  1. Gyula84

    Gyula84

    Joined:
    May 17, 2021
    Posts:
    1
    Assets\Scripts\Network\CustomNetworkManager.cs(13,26): error CS0115: 'CustomNetworkManager.OnServerAddPlayer(NetworkConnection)': no suitable method found to override

    I followed a tutorial on multiplayer and this is the only error I got.(I also use Mirror, Steamworks)
    I tried to search up this issue, one mentioned that new arguments where added to the method, but adding them couldn't help, maybe because the tutorial's creator used an older version of Mirror.


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Mirror;
    5. using UnityEngine.SceneManagement;
    6. using Steamworks;
    7.  
    8. public class CustomNetworkManager : NetworkManager
    9. {
    10.     [SerializeField] private PlayerObjectController GamePlayerPrefab;
    11.     public List<PlayerObjectController> GamePlayers { get; } = new List<PlayerObjectController>();
    12.  
    13.     public override void OnServerAddPlayer(NetworkConnection conn)
    14.     {
    15.         if (SceneManager.GetActiveScene().name == "Lobby")
    16.         {
    17.             PlayerObjectController GamePlayerInstance = Instantiate(GamePlayerPrefab);
    18.             GamePlayerInstance.ConnectionID = conn.connectionId;
    19.             GamePlayerInstance.PlayerIdNumber = GamePlayers.Count + 1;
    20.             GamePlayerInstance.PlayerSteamID = (ulong)SteamMatchmaking.GetLobbyMemberByIndex((CSteamID)SteamLobby.Intance.CurrentLobbyID, GamePlayers.Count);
    21.  
    22.             NetworkServer.AddPlayerForConnection(conn, GamePlayerInstance.gameObject);
    23.         }
    24.     }
    25. }
     
  2. LeanneCreed21

    LeanneCreed21

    Joined:
    May 26, 2021
    Posts:
    7
    I'm having this issue as well. Anyone got a solution to this?
     
  3. skip2join

    skip2join

    Joined:
    May 18, 2021
    Posts:
    1
    Try NetworkConnectionToClient instead of NetworkConnection, it worked for me.
     
  4. Voxstern

    Voxstern

    Joined:
    Sep 24, 2022
    Posts:
    8
    Did you ever figure it out? I'm having this problem