Page 1 of 1

unity3 and smartfox user variables

Posted: 15 Oct 2010, 13:45
by appels
Hi,

I'm trying to use user variables in SmartFox to spawn my player's avatar type but it's working for now.
what i have is this :

Code: Select all

   void onUserEnterRoom(int roomId, User user) {
      Hashtable uVars = new Hashtable();
      uVars = user.GetVariables();
      aTypes.Add(user.GetId(), uVars["avatarType"]);


As soon as a player enters the room, i retrieve the variables.
That part works fine when i debug it.
Now in my remote player spawn function i try this :

Code: Select all

string tmp = GetVars.aTypes[user.GetId()].ToString();


but when i do that i get following error from unity :

NullReferenceException: Object reference not set to an instance of an object
PlayerSpawnController.SpawnRemotePlayer (SmartFoxClientAPI.Data.User user) (at Assets/Scripts/PlayerSpawnController.cs:52)
PlayerSpawnController.SpawnRemotePlayers () (at Assets/Scripts/PlayerSpawnController.cs:45)
PlayerSpawnController.SpawnPlayers () (at Assets/Scripts/PlayerSpawnController.cs:22)
UnityEngine.Component:SendMessage(String)
GetVars:OnJoinRoom(Room) (at Assets/Scripts/GetVars.cs:52)
SmartFoxClientAPI.SmartFoxClient:_DispatchEvent(SFSEvent)
SmartFoxClientAPI.SmartFoxClient:ProcessEventQueue()
GetVars:FixedUpdate() (at Assets/Scripts/GetVars.cs:47)


Anyone have an idea ?

Re: unity3 and smartfox user variables

Posted: 05 Aug 2012, 17:47
by Carl Lydon
I get the same thing in SFS2X unity C#
The docs are not good.

Re: unity3 and smartfox user variables

Posted: 07 Aug 2012, 09:55
by rjgtav
Hi.
Have you checked the Object Movement example, which shows how to set and retrieve user variables?

[EDIT]
You can also check this topic:
viewtopic.php?f=20&t=14614

Re: unity3 and smartfox user variables

Posted: 07 Aug 2012, 17:42
by Carl Lydon
I just switched to retrieving the variables individually, instead of using getVars and now it works.