I have a little problem with SetUserVariables method in unity~C#. The only thing I tried to do was changing the value of my user variables in the server. As simple as that.
Server-side (extension):
Once an user has loged in successfully, I declare his user variables. I initialise both to zero and I let them be for a later client manipulation.
Client-side:
I handle login responses well. After loging, I load the level corresponding to the room where my player is in the server. I have done a functionally public chat, etc, and now I wanted to move my player around, so that's the reason why I wanted to use "SetUserVariables".
Here is the code in the Update() loop:
Code: Select all
void Update(){
...
Hashtable UV = new Hashtable();
UV.Add("x", 1);
UV.Add("y", 1);
smartFox.SetUserVariables(UV);
...
}
In the beginning, there were some transform manipulations, but I started to erase code in order to see what was wrong, and now I have only that 4 sentences.
User variables are initialised both to zero when I create them just after loging (in server-side) so, I only expected to see the change from 0 to 1. The name of the variables is the same as in the server, and they are numeric type.
But then , the error comes from debug message: "NullReferenceException: Object reference not set to an instance of an object".
I copied the sentences above from the c# api reference. I have also move it to diferent parts of the code and even to diferent working scripts, with the same results everywhere. I'm sure smartfox client is running, because I can chat, etc.
I have no more ideas to test, so you guys are the only answer!