Level Design with zay-es and networking

Hello dear community,

I want to develop a multiplayer game and for that I want to use zay-es. However, I thought about it and couldn’t find a solution to my problem which I want to describe now:

For my game I need to design an island. My plan is to add models directly to the scene, mark them with their type (added as user data) and make them to entities when the game is loaded.

It’s only the Server who is allowed to create the entities. The Client later receives the created entities. But here is the problem: How does the Client know which Entity belongs to which spatial in the scene. The Client also loads the game world (the island in this case) and somehow has to make a connection between the received Entity and the spatial the Entity belongs to.

I hope you see the problem…

Is there a solution for that?

Best regards
Domenic

Probably the easiest way is to let the server manage the entities and let the client create the visuals for those entities on the fly. This implies that if you want to use something like the scene editor to place the spatials for your entities that you will need a second pass (a simple utility or something) that would scan your scene for entities and then write that information out to a file.

Then the server would load that file, instantiate those entities, etc… and client would then load a version of the scene that does not have any entities in it. (They could have been stripped out as part of the import process above.) The server would send it the entity information it needs to reconstruct the objects.

Otherwise, the option is to strictly manage your entity IDs such that the client and server can know they are talking about the same thing. This seems kind of fragile to me since one mistake might have the couches walking around like storm troopers or whatever.

1 Like

Really thanks for the answer. I’ll try that.

Would you define static physic objects as game objects? Rather not, right? Let’s take the Island: There are a lot of trees, Palms and so on. They have a collision box (or someting similar) for physics collison but they are static (mass = zero). Normally you would manage all phyisc entities with a phyiscs system. But in this case I would just say those Palms and trees are no entities but are still added to physic space.

For non interactive objects this works, but for phyisc objects you can interact with e.g. a door this does not work anymore.

For me, every physical object would be an entity. I don’t see what you gain avoiding that. The same amount of data is required either way, really.

Else, every time you want to slide tree 1526 a little to the left you have to distribute a whole new client.

Well, at least you know they won’t hit anything. :wink:

Okay.

How would do it for the terrain which only exists in that scene? The terrain is also a static physical object. Should I save it in a separate j3o file too?

Physics is on the server… so every static physical object should be represented on the server in some way. However you do that.

@pspeed your approach is a good one but I decided to follow another one. I use a custom AppState, I called it LevelDesignerAppState, which I attach to the scene in the scene composer and the app state basically just frequently looks for nodes that have a special user data added and then the right model for that “entity” is loaded and attached to that node. Now it is very easy to move it around, rotate etc.

As you said @pspeed the server than scans the scene for entities,creates them.

The only thing I can optimize (for the client) is that I could remove all nodes with this special user data from the scene. But do empty nodes affect performance significantly?