//from the server: a networked game object has been instantiated
    public void OnNetInstantiate(SocketIOEvent e)
    {   
        //this is the data coming from the server as JSON, it needs to be parses into
        //usable variables according to a serializable class defined at the bottom of this script
        InstantiationData data = JsonUtility.FromJson<InstantiationData>(e.data.ToString());

        //print("Net instantiate " + data.uniqueId+" "+ data.position);

        //see if there is already an object with that id
        GameObject o = GameObject.Find(data.uniqueId);
        
        //if not instantiate on the scene
        if(o == null)
           o = Instantiate(Resources.Load(data.prefabName) as GameObject);

        
        o.transform.position = data.position;
        o.transform.localScale = data.localScale;
        o.transform.rotation = data.rotation;
        o.name = data.uniqueId;
        

        //fetch or add the netcomponent object
        NetObject netObj = o.GetComponent<NetObject>();

        if (netObj == null)
        {
            netObj = o.AddComponent<NetObject>();
        }

        netObj.type = data.type;
        netObj.owner = data.owner;
        netObj.prefabName = data.prefabName;
        
        Net.objects[data.uniqueId] = netObj;

       netObj.OnVariableInit();
    }