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 siOnzeeSlav · Jul 04, 2013 at 02:23 AM · serverrpcnull

Server don't receiving RPC values

Hi. There is my code, I using new pro version of Unity 3D.

 public static string playerName = "EMPTY";
 
 void OnConnectedToServer() {
     //CLIENT SIDE
     networkView.RPC("setPlayerName", RPCMode.All);
 }
 
 [RPC]
 public void setPlayerName() {
     Debug.Log(Login.playerName);
     playerName = Login.playerName; // Login is a class.
 }
 
 //This part working great, but server don't receive username.
 
 
 void OnPlayerConnected(NetworkPlayer player) {
     //SERVER SIDE
     notification = playerName + xxxx; // Here playerName == EMPTY. Why ?
 }

I have attached to main camera -- networkView, and scripts.

Comment
Add comment · Show 18
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
avatar image moha · Jul 04, 2013 at 07:47 AM 0
Share

you don't give any value in the networkview and rpc function

networkView.RPC("setPlayerName", RPC$$anonymous$$ode.All, username);

[RPC] public void setPlayerName(string username) { Debug.Log(Login.playerName); playerName = Login.playerName; // Login is a class. }

You can use the following variable types as parameters to RPCs:-

int float string NetworkPlayer NetworkViewID Vector3 Quaternion

avatar image Benproductions1 · Jul 05, 2013 at 08:23 AM 0
Share

So you're saying that your RPC is not sending any information, when you're not telling it to send anything
Then you say you're not receiving anything either... maybe because you're not telling it that you can recieve something...

sigh

avatar image siOnzeeSlav · Jul 08, 2013 at 11:35 PM 0
Share

Ok guys, I now have

 public string user = "E$$anonymous$$PTY";
 
 public void Connect(string username) {
 Network.Connect("ip", port, "password");
 Debug.Log(username); // Here username return "siOnzee".
 setNickName(username);
 }
 
 public void setNickName(string username) {
 networkView.RPC("setPlayerName", RPC$$anonymous$$ode.All, username); // Here I got NullReferenceException Network$$anonymous$$anager.setNickName (System.String username) (at Assets/C#/Network$$anonymous$$anager.cs:85)
 }
 
 [RPC]
 public void setPlayerName(string username) {
 Debug.Log(username);
 user = username;
 }

What I now doing wrong ?

avatar image Benproductions1 · Jul 09, 2013 at 12:01 AM 0
Share

Firstly, you aren't indenting -_-

Secondly, you need a NetworkView attached to the object for this to work.

avatar image siOnzeeSlav · Jul 09, 2013 at 12:39 AM 0
Share

To first: I have indenting, but I removed it here. I have networkView attached to $$anonymous$$ain Camera on server side and client side too. Screens:

Client SIDE Client Side

Server SIDE Server Side

Core:

 public class Core : $$anonymous$$onoBehaviour {
 
     private $$anonymous$$ySQL mysql;
     private Network$$anonymous$$anager network$$anonymous$$anager;
     private Login login;
     private FirstPlay firstplay;
     private Hud hud;
     private Loading loading;
     private Typ typ;
 
     void Start () {
         mysql = new $$anonymous$$ySQL(this);
         network$$anonymous$$anager = new Network$$anonymous$$anager(this);
         login = new Login(this);
         firstplay = new FirstPlay(this);
         hud = new Hud(this);
         loading = new Loading(this);
     }
 
     public $$anonymous$$ySQL get$$anonymous$$ySQL() { return mysql; }
 
     public Network$$anonymous$$anager getNetwork$$anonymous$$anager() { return network$$anonymous$$anager; }
 
     public Login getLogin() { return login; }
 
     public FirstPlay getFirstPlay() { return firstplay; }
 
     public Hud getHud() { return hud; }
 
     public Loading getLoading() { return loading; }
 
 }
 

on$$anonymous$$ouseDown Login I call: core.getNetwork$$anonymous$$anager().Connect(username.text);

     public void Connect(string username) {
         Network.Connect("127.0.0.1", 25000, "frelaniaAAAGa$$anonymous$$eeee4156");
         Debug.Log(username);
         setNickName(username);
     }
 
     public void setNickName(string username) {
         networkView.RPC("setPlayerName", RPC$$anonymous$$ode.All, username);
     }
 
     [RPC]
     public void setPlayerName(string username) {
         Debug.Log(username);
         user = username;
     }
 
     void OnPlayerConnected(NetworkPlayer player) {
         //SERVER
         if (Network.isServer) {
             notification = user + " has connected.";
             writeToLog(notification);
             Debug.Log("Player " + user + " has connected.");
             PlayerList.Add(user);
         }
     }
Show more comments

0 Replies

· Add your reply
  • Sort: 

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

17 People are following this question.

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

Related Questions

Really quick/easy question about RPCs 1 Answer

RPC called with a viewID, reaching server with a different viewID 1 Answer

accessing to one array from another script 2 Answers

Server RPC 1 Answer

UNET Make every player execute a function locally 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