// Player clicked play -> then server calls this callback function. private void OnUserPlay(SocketIOEvent evt) { Debug.Log("OnUserPlay"); loginController.gameObject.SetActive(false); directionController.gameObject.SetActive(true); directionController.DirectionAction(); chat.gameObject.SetActive(true); chat.ActivateChat(); GameObject selfObj = Instantiate(player, player.transform.position, Quaternion.identity); PlayerScript self = selfObj.GetComponent <PlayerScript> (); string name = JsonConverter.JsonToString(evt.data.GetField("name").ToString(), "\""); string room = JsonConverter.JsonToString(evt.data.GetField("room").ToString(), "\""); Vector3 pos = JsonConverter.JsonToVector3(evt.data.GetField("position").ToString()); self.SetPlayer(name, room, pos); directionController.SetPlayer(self.gameObject, speed); // get other players to render them. socket.Emit("get_players"); }