Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Assets\CustomNetworkManager.cs(13,26): error CS0115: 'CustomNetworkManager.OnServerAddPlayer(Network

Discussion in 'Multiplayer' started by Blazeist, Feb 26, 2023.

  1. Blazeist

    Blazeist

    Joined:
    Feb 23, 2023
    Posts:
    1
    Can anyone help me with this problem im having?

    Here's the script:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using Mirror;
    using UnityEngine.SceneManagement;
    using Steamworks;

    public class CustomNetworkManager : NetworkManager
    {
    [SerializeField]private PlayerObjectController GamePlayerPrefab;
    public List<PlayerObjectController> GamePlayers { get; } = new List<PlayerObjectController>();

    public override void OnServerAddPlayer(NetworkConnection conn)
    {
    if(SceneManager.GetActiveScene().name == "Lobby")
    {
    PlayerObjectController GamePlayerInstance = Instantiate(GamePlayerPrefab);

    GamePlayerInstance.ConnectionID = conn.connectionId;
    GamePlayerInstance.PlayerIdNumber = GamePlayers.Count + 1;
    GamePlayerInstance.PlayerSteamID = (ulong)SteamMatchmaking.GetLobbyMemberByIndex((CSteamID)SteamLobby.Instance.CurrentLobbyID, GamePlayers.Count);

    NetworkServer.AddPlayerForConnection(conn, GamePlayerInstance.gameObject);
    }
    }
    }
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,108
    Please use code tags.
    The error message you get tells you a lot about what's wrong actually, and also where ("13,26" reads as: line 13, character 26). Remove the override.