Hi all, I'm evaluating SFS for use with future Unity projects, and right now I'm running through the Flash-based examples and trying to convert them to Unity. One more caveat, I'm doing it in the Javascript-y flavor of Unity scripting to see if it works and also because most of our script library is in that language and we'd like to see if SFS will play nice with that. At any rate, I'm trying to convert the "Avatar Chat" example to a 3D avatar chat example, and I'm having trouble keeping track of avatar positions. In the SmartFox class, I handle creating avatars on joining a room, and none of the other users have any variables associated with them when I run the following (where user is any given User from the room's userlist):
Code: Select all
if (user.GetId() != client.myUserId) {
var uVars : Hashtable = user.GetVariables();
var debugString : String = "User " + user.GetId() + " variables: ";
for (var uVar : String in uVars.Keys) {
debugString += uVar + ", ";
}
Debug.Log(debugString);
// ... and so on
The debug statement shows no variables for the user. In the same function, after other player's avatars are created locally, I instantiate a localAvatar with the FPSWalker and the following script attached:
Code: Select all
var smartFox : SmartFox;
var myPos : Hashtable = new Hashtable();
var myOldPos : Vector3;
function Awake () : void {
smartFox = GameObject.FindObjectOfType(SmartFox);
myOldPos = transform.position;
}
function Start () : void {
myPos.Add("px", transform.position.x);
myPos.Add("py", transform.position.y);
myPos.Add("pz", transform.position.z);
smartFox.client.SetUserVariables(myPos);
}
function FixedUpdate () : void {
if (myOldPos != transform.position) {
myPos["px"] = transform.position.x;
myPos["py"] = transform.position.y;
myPos["pz"] = transform.position.z;
smartFox.client.myRoom.GetUser(smartFox.client.myUserId).SetVariables(myPos);
myOldPos = transform.position;
}
}
Am I doing something wrong in setting user variables? I couldn't find an example of setting user vars in the Unity specific tutorials, so I'd appreciate any guidance in the matter. Thanks in advance.