Sending level over to other players

Options
Mikle
Mikle
Hello,

I have a leveldesigner in my game where every player can create his own levels.

I want the host to be able to play a level that he created without the other players need to download it from anywhere. (Stronghold Crusader for example manages to do this)
If I send the data via RPC the level gets loaded but the connection drops after its done loading.
I can load it without getting cicked if I yield a second but it takes forever to load if I do it like this.

This gets called for every chunk from another object when loading the scene:

[PunRPC]
public void Load(Vector3 position, Vector3[] vert, Vector3[] norm, Vector2[] uv, int[] tri, bool fluid)
{
Material _material = null;
Transform _parent = null;

if (!fluid)
{
_parent = LoadIngameLevel.GetInstance.Level.GetChild(0);
_material = LoadIngameLevel.GetInstance.normalMaterial;
this.gameObject.tag = "Chunk";
}
else
{
_parent = LoadIngameLevel.GetInstance.Level.GetChild(1);
Fluid _fluid = this.gameObject.AddComponent();
}

transform.SetParent(_parent);
transform.position = position;

Mesh mesh = new Mesh();
MeshFilter meshFilter = (MeshFilter)this.gameObject.AddComponent();
MeshRenderer meshRend = this.gameObject.AddComponent();
meshRend.material = _material;

mesh.vertices = vert;
mesh.normals = norm;
mesh.uv = uv;
List suvs = new List();
mesh.SetUVs(1, suvs);
mesh.triangles = tri;

mesh.RecalculateBounds();

meshFilter.mesh = mesh;

MeshCollider meshCol = this.gameObject.AddComponent();
meshCol.sharedMesh = meshFilter.mesh;
}

Please help!

Thanks alot!!

Comments

  • Tobias
    Options
    How much data maximum is such a level?
    In best case, you "upload" the level somewhere, assign an ID and send that inside of Photon, so everyone can download it. It's better not to use the realtime communication for such time consuming transfers.