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
0
Question by adriel0000 · Jun 29, 2014 at 05:44 PM · multiplayernetwork

Problem with RPC attribute.

Hi! I have a problem, and i cant solve this :( I tried about 1 month to fix it, but i cant solve this problem :(

Problem:

 RPC call failed because the function 'SendFullPlayers' in 'LobbyUI' does not have the RPC attribute. You need to add the RPC attribute in front of the function declaration
 UnityEngine.NetworkView:RPC(String, RPCMode, Object[])
 LobbyUI:Update() (at Assets/Escenas/Nivel1/Lobby/LobbyUI.js:33)

Code:

 private var Menu = 1;
 
 var ButtonSolo : GUIStyle;
 var ButtonCoop : GUIStyle;
 var ButtonCrearPartida : GUIStyle;
 var ButtonUnirseAPartida : GUIStyle;
 var ButtonUnirse : GUIStyle;
 var ButtonComenzar : GUIStyle;
 
 var remoteIP:String = "127.0.0.1";
 var IP:String = "IP DEL SERVIDOR";
 var remotePort = 25002;
 var useNAT = false;
 static var Jugadores = 1;
 static var Spawn:int;
 static var Servidor:int;
 static var Jugando;
 static var ClienteFijo;
 var ClienteFijoTiempo = 0;
 
 function Start(){
 networkView.group = 1;
 }
 function Update(){
 if(Servidor==1){
 if(Jugadores==2){
     networkView.RPC("SendPlayers",RPCMode.All);
     //SendPlayers2();
 }
 if(Jugadores==3){
     //SendPlayers3();
     networkView.RPC("SendFullPlayers",RPCMode.All);
 }
 }
 
 if(Servidor==0 && ClienteFijoTiempo>=10 && ClienteFijoTiempo <= 6020){
 ClienteFijoTiempo -= Time.deltaTime;
 }
 
 if(Servidor==0 && ClienteFijo==0 && Jugadores <=2 && ClienteFijoTiempo>=6000)
 ClienteFijo = 1;
 ClienteFijoTiempo = 0;
 }
 
 if(Servidor== 0 && ClienteFijo==0 && Jugadores >=3){
 Network.Disconnect();
 MasterServer.UnregisterHost();
 Menu = 1;
 }
 
 
 function OnGUI () {
 
 if(Screen.width<=1366 && Screen.height<=768){
 if(Menu==1){ //Menu Principal 720p
     if(GUI.Button (Rect(Screen.width/2.4,Screen.height/3.8,225,50),"",ButtonSolo)){
     Network.InitializeServer(32, 25002, useNAT);
     StartGame();
     networkView.RPC("StartGame",RPCMode.All);
     Destroy(gameObject);
     }
     if(GUI.Button (Rect(Screen.width/2.4,Screen.height/2.9,225,50),"",ButtonCoop)){
     Menu = 2;
     }
 }
 }
 
 if(Menu==2){ //MenuCoop
     if(GUI.Button (Rect(Screen.width/2.4,Screen.height/3.8,225,50),"",ButtonCrearPartida)){
         Network.InitializeServer(32, 25002, useNAT);
         Menu = 3;
     }
     
     if(GUI.Button (Rect(Screen.width/2.4,Screen.height/2.9,225,50),"",ButtonUnirseAPartida)){
     Menu = 4;
     }
 }
 
 if(Menu==3){ //MenuCrearPartida---------------------------
         if(Jugadores==1){
         GUI.Box(Rect(Screen.width/2.4,Screen.height/3.8,225,50),"Jugadores 1/2");
         }
         if(Jugadores==2) {
         GUI.Box(Rect(Screen.width/2.4,Screen.height/3.8,225,50),"Jugadores 2/2");
         }
 
     if(GUI.Button (Rect(Screen.width/2.45,Screen.height/3,225,50),"",ButtonComenzar)){
          StartGame();
          networkView.RPC("StartGame",RPCMode.AllBuffered);
     }
 }
 
 if(Menu==4){ //MenuUnirseAPartida--------------------
     if(GUI.Button (Rect(Screen.width/2.45,Screen.height/3,225,50),"",ButtonUnirse)){
          Network.Connect(IP, remotePort);
          Servidor = 0;
     }
     IP = GUI.TextField (Rect(Screen.width/2.4,Screen.height/3.8,200,20), IP, 25);
 }
 
 if(Menu==5){ //MenuPartidaUnida
 if(Servidor==0){
 if(Jugadores==1) {
         GUI.Box(Rect(Screen.width/2.4,Screen.height/3.8,220,20),"Jugadores 1/2");
 }
 if(Jugadores==2) {
         GUI.Box(Rect(Screen.width/2.4,Screen.height/3.8,220,20),"Jugadores 2/2");
 }
 if(Jugadores==3) {
         GUI.Box(Rect(Screen.width/2.4,Screen.height/3.8,220,20),"Jugadores 3/3");
 }
 if(GUI.Button (Rect(Screen.width/2.45,Screen.height/3,225,50),"",ButtonComenzar)){
          StartGame();
          networkView.RPC("StartGame",RPCMode.AllBuffered);
     }
 }
 }
 }
 
 
 function OnConnectedToServer() {
 Menu = 5;
 if(ClienteFijo==0){
 ClienteFijoTiempo = 10;
 }
 }
 
 function OnServerInitialized() {
 Servidor = 1;
 }
 
 function OnPlayerConnected(player: NetworkPlayer) {
 if(Servidor== 1){
 Jugadores += 1;
 }
 }
 
 function OnPlayerDisconnected(player: NetworkPlayer) {
 if(Servidor==1){
         Network.RemoveRPCs(player);
         Jugadores -= 1;
         }
 }
 
 @RPC
 function SendPlayers(){
 Jugadores = 2;
 }
 function SendFullPlayers(){
 Jugadores = 3;
 /*Network.Disconnect();
 MasterServer.UnregisterHost();
 Menu = 1;*/
 }
 function StartGame(){
 Destroy(gameObject);
 Spawn = 1;
 Jugando = 1;
 }



Thank you for your time :)

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 KiraSensei · Jun 29, 2014 at 05:45 PM

 @RPC
 function SendFullPlayers(){
 Jugadores = 3;
 /*Network.Disconnect();
 MasterServer.UnregisterHost();
 Menu = 1;*/
 }

the "@RPC" you have is applied only to the next function only (SendPlayers), not the ones after.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Doubt about Network level loading 0 Answers

Can you create a Stand alone server for your game? 0 Answers

Online Multiplayer 1 Answer

Multiplayer. Destroying player object on Host/Server 2 Answers

Networking, players can't see each others movements 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