Hello! I’m working on a editable tile base game right now. At first I don’t have any issues with syncing my tiles in all clients while using the oriented brush because the parent object has the sprite and network identity component on it. And once I tried to paint and NetworkServer.Spawn the new tile, it will just disable that old object and spawn a new object perfectly in all of my clients. But I noticed that I have some issues with the edge bleeding once I have a lot of tiles on screen.
So I tried to use tileset instead of the oriented brush. It did manage to fix the edge bleeding issue but there’s a problem. For some reason my server can’t send the modified tile to the newly connected clients. I think it’s because tileset brushes handles sprite differently. Before for each tile I have one prefab that contains its sprite and network identity. Now, the tile system handle the sprite rendering and I can’t locate it where it happens.
I tried doing [Command] and [ClientRpc] approach. In my command, it just calls the clientrpc function which is the one who will paint the tile. And I also tried with just one command function which will get the tile data of the painted tile and get the child of the gameobject of the tile data and networkserver.spawn it. All of this approach will sync it in all clients but once the user tries to disconnect and try to connect. The latter approach will managed to spawn the object (which you’ll see on the scene objects) but the sprite of the tile is not updated.
Do you have any suggestion? I’m creating a harvest moon like game by the way.
Thanks
You need to buffer messages to inform new clients of changes to a default world that happened before they joined, right?
I had thought unet had some built in way to do that, but I can’t remember if I’m just thinking of legacy buffered rpc methods. Anyway you could just keep collections for “changes made” up to the point of the current world… well more of a “different than the default world” collection, that when a new user connects, have em hit a loading screen, then run lots of the regular changes (just how you update the world as if they were connected already at the time of the change) all at once to match the up to date world…
I hope that makes sense, can’t come up with better advice for ya.
1 Like
I thought about that approach but is it ok if I don’t use the NetworkServer.Spawn? I’m thinking about just handling everything by myself. This is the first time I’m doing a game with networking so I don’t know which is the right thing to do.
Most of the tutorials I found uses NetworkServer.Spawn when spawing objects. I’m thinking of just having a list of all the updated tiles then just do [Command] and [ClientRpc] calls where the [ClientRpc] function will do a GameObject.Instantiate. Then when new user joined it, I’ll just do what you’ve said.
Thanks
You certainly can do that, and often you can do things which require unique circumstances a little easier that way. I’d say make sure only the server/host does that sort of thing, and the variables, positions and such are handed off to clients, but yeah should work fine though.
If you want to make sure you do it the same way higher level unet does, perhaps look into jetbrains dot peek to dig into the code, and see exactly what Network.Spawn() does…