I am using the 'Socket.IO for Unity' plugin and sending data to the server using JSONObject, but I can't convert from string to float.
Using:
Debug.Log(e.data.GetField("vertical").ToString());
Correctly returns me the string "0,978"
But 'float.Parse' works with any string except from a JsonObject, such as taking the JsonObject string above and using float.Parse:
float.Parse (e.data.GetField("vertical").ToString())
Simply interrupting the rest of the code without any console errors, the game goes on perfectly but without returning the float! What may be happening? Does anyone have any ideas?
My code:
public void PlayerAnim(SocketIOEvent e){
if(e.data.GetField("id").ToString () == id){
anim.SetFloat ("IsRunning", Mathf.Abs (float.Parse (e.data.GetField("vertical").ToString()) + Mathf.Abs (float.Parse (e.data.GetField("horizontal").ToString()))));
}
}