Code: Select all
userVariables.Add (new SFSUserVariable ("x", (double)_tempPos.x));
userVariables.Add (new SFSUserVariable ("y", (double)_tempPos.y));
userVariables.Add (new SFSUserVariable ("z", (double)_tempPos.z));
So to condense the amount of variables and possible overhead I decided to push data to an SFSArray so I could store the entire vector in a single variable but I'm getting odd results, my data isn't coming back correct and players are flying all over the place.
Here is an example of the sending and recieving of my data:
Sending:
Code: Select all
//Rig position
if (localPlayer.transform.position != lastPosRig) {
_tempPos = localPlayer.transform.position;
_cordArray [0] = _tempPos.x;
_cordArray [1] = _tempPos.y;
_cordArray [2] = _tempPos.z;
SFSArray _dataArray = new SFSArray ();
_dataArray.AddFloatArray (_cordArray);
userVariables.Add (new SFSUserVariable ("xyz", _dataArray));
lastPosRig = _tempPos;
hasChanged = true;
}
Recieving:
Code: Select all
//Rig Position
if (_changedVars.Contains ("xyz")) {
_newData = _userData.GetVariable ("xyz").GetSFSArrayValue ().GetFloatArray (0);
remotePlayers [_userData.Name].rigInterp.SetPosition (new Vector3 ((float)_newData[0], (float)_newData[1], (float)_newData[2]), true);
}