Search Unity

CS0115 ..."is marked as an override but no suitable method found to override" and general problem

Discussion in 'Multiplayer' started by pKallv, Jan 4, 2016.

  1. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,191
    I am pretty lost and try to do add a player with code with the following code:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.Networking;
    4.  
    5. public class PlayerSpawner : NetworkBehaviour {
    6.  
    7.     public GameObject playerPrefab;
    8.  
    9.     public override void OnStartClient () {
    10.         print ("OnStartClient");
    11.  
    12.         ClientScene.AddPlayer (playerPrefab);
    13.  
    14.     }
    15.  
    16.  
    17.     public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId, NetworkReader extraMessageReader)
    18.     {
    19.         print ("OnServerAddPlayer");
    20.         OnServerAddPlayer(conn, playerControllerId, extraMessageReader);
    21.     }
    22.  
    23. }
    1) I get the following error i do not understand how to solve:
    2) Read the documentation etc. and tried a lot of things but need help to be able to spawn a player via code. Just can't get it to work, guess i do not understand fully.
     
  2. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    OnServerAddPlayer isn't defined in NetworkBehaviour and as such you can't override it. OnStartClient is only a message and as such, you can't override it either.
     
    pKallv likes this.
  3. snazzy_man1

    snazzy_man1

    Joined:
    Jul 17, 2020
    Posts:
    1
    Has anyone gotten this to work? I'm pretty lost myself...