private byte[] getSpawnBytes(IdentityAndTransform iat)       // list index means index in the IDAndTransforms list, and conn
    {
        ByteConstructor bc = new ByteConstructor();

        bc.addLevels(new int[] { (int)DataType.Sync, (int)SyncType.Spawning });
        bc.add(NetObjBytes.defaultInfo(iat.netIdentity.objID, iat.netIdentity.AuthorityID, (int)iat.type, iat.prefabIndex, iat.netTrans.trans.position, iat.netTrans.trans.rotation));
        switch (iat.type)
        {
        case NetObjBytes.ObjectType.Planet:
            var pg3 = iat.netIdentity.GetComponent <PlanetGenerator3> ();

            if (pg3 != null)
            {
                var rb = iat.netIdentity.GetComponent <ConstraintTrans> ().otherTrans.GetComponent <Rigidbody> ();
                bc.add(NetObjBytes.planetSpawn(rb.mass, rb.velocity, rb.angularVelocity, pg3.seed, pg3.radius));
            }
            else
            {
                var rb = iat.netIdentity.GetComponent <Rigidbody> ();
                bc.add(NetObjBytes.planetSpawn(rb.mass, rb.velocity, rb.angularVelocity, 0, 0));
            }
            break;

        case NetObjBytes.ObjectType.Rigidbody:
            var rb1 = iat.netIdentity.GetComponent <ConstraintTrans> ().otherTrans.GetComponent <Rigidbody> ();
            bc.add(NetObjBytes.rigidbodySpawn(rb1.mass, rb1.velocity, rb1.angularVelocity));
            break;
        }

        return(bc.getBytes());
    }
    private void receiveSpawn(byte[] data)      // Receives a spawn request
    {
        createLightEnable();

        int objID        = System.BitConverter.ToInt32(data, 0); //Converting data to int
        int indexOfFound = findIndexByID(objID);                 // try and find an object with the same netID

        if (indexOfFound != -1)                                  // if object was found, destroy it
        {
            destroyObject(indexOfFound);
        }

        IdentityAndTransform idTransLocal;

        NetObjBytes.receiveObject(data, out idTransLocal);          //Hand all of the spawning data to the NetObjSpawn Class function "receiveObject"
        IDAndTransforms.Add(idTransLocal);
    }