Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by GiannisGamwa · Sep 07, 2012 at 08:31 PM · errornetworkingplayerspawn

RPC Call Error/Failed

Hello I've got this error when a other user try to spawn : "RPC call failed because the function 'Client_ServerLoaded' does not exist in any script attached to'PlayerManager'"

Whole Script:

using UnityEngine;

 using System.Collections;
 
 using System.Collections.Generic;
 
 public class MultiplayerManager : MonoBehaviour 
 {
     public static MultiplayerManager instance;
     
     public string PlayerName;
     
     private string MatchName = "";
     private string MatchPassword = "";
     private int MatchMaxUsers = 32;
     
     public List<MPPlayer> PlayerList = new List<MPPlayer>();
     public List<MapSettings> MapList = new List<MapSettings>();
     
     public MapSettings CurrentMap = null;
     public int oldprefix;
     public bool IsMatchStarted = false;
     
     //General Multiplayer Modes
     public bool MatchLoaded;
     public MPPlayer MyPlayer;
     public GameObject[] Spawnpoints;
     
     
     void Start()
     {
         instance = this;
         PlayerName = PlayerPrefs.GetString("PlayerName");
         CurrentMap = MapList[0];
         DontDestroyOnLoad(gameObject);
     }
     
     void FixedUpdate()
     {
         instance = this;    
     }
     
     public void StartServer(string servername, string serverpassword, int maxusers)
     {
         MatchName = servername;
         MatchPassword = serverpassword;
         MatchMaxUsers = maxusers;
         Network.InitializeServer(MatchMaxUsers , 2550, false);
         MasterServer.RegisterHost("DeathMatch", MatchName, "");
         //Network.InitializeSecurity();
     }
     
     void OnServerInitialized()
     {
         Server_PlayerJoinRequest(PlayerName, Network.player);
     }
     
     void OnConnectedToServer()
     {
         networkView.RPC("Server_PlayerJoinRequest", RPCMode.Server, PlayerName, Network.player);
     }
     
     void OnPlayerDisconnected(NetworkPlayer id)
     {
         networkView.RPC("Client_RemovePlayer", RPCMode.All, id);
     }
     
     void OnPlayerConnected(NetworkPlayer player)
     {
         foreach(MPPlayer pl in PlayerList)
         {
             networkView.RPC("Client_AddPlayerToList", player, pl.PlayerName, pl.PlayerNetwork);
         }
             networkView.RPC("Client_GetMultiplayerMatchSettings", player, CurrentMap.MapName, "", "");
     }
     
     
     [RPC]
     void Server_PlayerJoinRequest(string playername, NetworkPlayer view)
     {
                 
     networkView.RPC("Client_AddPlayerToList", RPCMode.All, playername, view);
     }
     
     [RPC]
     void Client_AddPlayerToList(string playername, NetworkPlayer view)
     {
         MPPlayer tempplayer = new MPPlayer();
         tempplayer.PlayerName  = playername;
         tempplayer.PlayerNetwork = view;
         PlayerList.Add(tempplayer);
         if(Network.player == view)
         {
             MyPlayer = tempplayer;
         }
     }
     
     [RPC]
     void Client_RemovePlayer(NetworkPlayer view)
     {
         MPPlayer temppl = null;
         foreach(MPPlayer pl in PlayerList)
         {
             if(pl.PlayerNetwork == view)
             {
                 temppl = pl;
             }
         }
         if(temppl != null)
         {
             PlayerList.Remove(temppl);
         }
     }
     
     [RPC]
     void Client_GetMultiplayerMatchSettings(string map, string mode, string others)
     {
         CurrentMap = GetMap(map);
     }    
     
     public MapSettings GetMap(string name)
     {
         MapSettings get = null;
         
         foreach(MapSettings st in MapList)
         {
             if(st.MapName == name)
             {
                 get = st;
                 break;
             }
         }
         
         return get;
     }
     
     [RPC]
     void Client_LoadMultiplayerMap(string map, int prefix)
     {
         Network.SetLevelPrefix(prefix);
         Application.LoadLevel(map);
     }
     
     void OnGui()
     {
         if(!MyPlayer.PlayerIsAlive)
             SpawnMenu();
     }
     
     [RPC]
     void Server_SpawnPlayer(NetworkPlayer player)
     {
         int numberspawn = Random.Range(0, Spawnpoints.Length - 1);
         networkView.RPC("", RPCMode.All, player, Spawnpoints[numberspawn].transform.position, Spawnpoints[numberspawn].transform.rotation);
     }
     
     [RPC]
     void Client_SpawnPlayer(NetworkPlayer player, Vector3 position, Quaternion rotation)
     {
         if(player == MyPlayer.PlayerNetwork)
         {
             MyPlayer.PlayerManager.ControllerTransform.position = position;
             MyPlayer.PlayerManager.ControllerTransform.rotation = rotation;
             MyPlayer.PlayerManager.networkView.RPC("Client_PlayerAlive",  RPCMode.Others);
         }
         else
         {
             
         }
     }
     
     void OnLevelWasLoaded()
     {
         if(Application.loadedLevelName == CurrentMap.MapLoadName)
         {
             MatchLoaded = true;
             Spawnpoints = GameObject.FindGameObjectsWithTag("spawnpoint");
         }
     }
     
     //Deathmatch
     void SpawnMenu()
     {
         if(GUI.Button(new Rect(5, Screen.height -40, 250, 35),"Spawn"))
         {
             if(Network.isServer)
                 Server_SpawnPlayer(Network.player);
             else
                 networkView.RPC("Server_SpawnPlayer", RPCMode.Server, Network.player);
         }
     }
 }
 [System.Serializable]
 public class MPPlayer
 {
     public string PlayerName = "";
     public NetworkPlayer PlayerNetwork;
     public PlayerManager PlayerManager;
     public int PlayerHealth = 100;
     public bool PlayerIsAlive;
     public int PlayerKills;
     public int PlayerDeaths;
 }
 [System.Serializable]
 public class MapSettings
 {
     public string MapName;
     public string MapLoadName;
     public Texture MapLoadTexture;
 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by e_Glyde · May 07, 2013 at 06:15 PM

Replace " MyPlayer.PlayerManager.networkView.RPC("Client_PlayerAlive", RPCMode.Others); " With " MyPlayer.PlayerManager.networkView.RPC("­Client_PlayerAlive", RPCMode.All); "

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

UNET Players not spawning on server change scene 1 Answer

Problem with spawn player with RPC calls(c #) 1 Answer

Network player duplicated when replacing player with a new one 1 Answer

Unique player spawning with networking 0 Answers

Spawn Player when Room Starts - (Multiplayer) 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges