Comments (26)
I create a diagram of the network idea of edit replication between all clients:
from marching-cubes-on-unity-3d.
thanks this is really good method but if i only send actions instead of chunk data, there might be a problem caused by synchronization. But if i remember correctly minecraft is struggling with that problem too. If you have a lag then someone place block before you. But since its a server auth environment, client has to obey server so there wont be desyn i hope
Yeah the idea is use the host as authory and for merge some edits (marching cubes world modification support multiple actions in the same point). So the system support better the lag problems that Minecraft world.
from marching-cubes-on-unity-3d.
The current system not have a multiplayer implemetnation but it's possible to support one. The main point is send three elements over the network:
- The world configuration: it's the class inside the NoiseManager used for the creation of the new chunks (not edited ones). You need send this one time, when the user connect to the server.
- The ChunkData: The chunk data contains the terrain data (all the modifications applied to the the terrain), in this case the server must send that data when a connected client load that area of the world. The data is in : Application.persistentDataPath >worlds > [WorldName].
- The real time modifications: You need replicate all the modifications from a client in the host and the other clients for the same state of the terrain in all users. Function that modify the terrain:
chunkManager.ModifyChunkData()
. You need send this each time user make a modification in any area of the game or to the current areas of the client and send the chunk data when client render a modified chunk.
The implementation is possible however you need a correct knowledge of the code of the project..
from marching-cubes-on-unity-3d.
Thx, for the answer, i'll try to implement those :)
from marching-cubes-on-unity-3d.
Any more doubts about this you can create new issue or continue in this one. Try to implement the three elements in the order of the list in my previous comment I think that's the easier order.
from marching-cubes-on-unity-3d.
Hi @Javier-Garzo , I've implemented multiplayer chunk system but chunk's data is too much for MTU. I tried to compress chunk data by using LZ4 and it compressed chunk data to 1k byte. But sometimes compression not works well and exceeds MTU which is roughly 1024 byte.
How can I compress chunk data better than generic compression algorithms?
Also I tried to implement lighting like minecraft, light spreads out to chunk vertices etc but the problem is: When player modifies chunk, we need to calculate light each time(using unity jobs). Do you have any idea about how can I improve performance?
from marching-cubes-on-unity-3d.
i'm working to get it working with Mirror
rn it can succesfully load chunks and work like normal on Host mode
(Doesn't need to send files with Mirror)
from marching-cubes-on-unity-3d.
@Diamantino-Op if your world is not modifiable then its easy to make it multiplayer but my world is editable and players can dig/build.
from marching-cubes-on-unity-3d.
mine too
from marching-cubes-on-unity-3d.
basically it loads world like normal, it spawn the chunks only on the server btw, and the server sends them to the client in real time
from marching-cubes-on-unity-3d.
basically it loads world like normal, it spawn the chunks only on the server btw, and the server sends them to the client in real time
did you check the chunk data size :D
its too much to send over network mine was 70k byte which is 70x bigger than MTU
from marching-cubes-on-unity-3d.
nope didn't check
from marching-cubes-on-unity-3d.
i think you can set the max message size here
from marching-cubes-on-unity-3d.
but you are using TCP based transport which automatically splits one big packet into chunks. Problem is not about sending chunk data, problem is its size is too much to send over network. Image you have 100ccu and players are wandering around the world. Its nearly impossible without some compression.
from marching-cubes-on-unity-3d.
then how can we do it?
from marching-cubes-on-unity-3d.
I don't know if it's possible to get a better comparison of the chunk I used in the CompressHelper.cs the Gzip algorithm, but I think LZ4 is better.
Similarly for the illumination I think you need recalculate the illumination each time because you build a new mesh each modification.
For the network chunk size problem, maybe I have a solution:
The idea is that you send to the user all the region data when he connect to the server, so the user have the current state of the game when end the load. At that point all edits action are sent to the server and this one use it to update his chunk data and send a compressed version of all edit actions in that frame to all clients. In this system the client must have all the region data loaded (or all regions where a user is playing) so he can modify the data of that chunk when the server send the modifications (low cost part). The client only creates the mesh of the user active chunks (that's the high cost part).
from marching-cubes-on-unity-3d.
i have done this for now if you are ineterested: https://github.com/Diamantino-Op/Mirror-Multiplayer-Macrhing-Cubes-Terrain
from marching-cubes-on-unity-3d.
this is my version (Has some bugs but "works")
from marching-cubes-on-unity-3d.
8Kbs network usage when loading a lot of chunks together
from marching-cubes-on-unity-3d.
I don't know if it's possible to get a better comparison of the chunk I used in the CompressHelper.cs the Gzip algorithm, but I think LZ4 is better. Similarly for the illumination I think you need recalculate the illumination each time because you build a new mesh each modification.
For the network chunk size problem, maybe I have a solution: The idea is that you send to the user all the region data when he connect to the server, so the user have the current state of the game when end the load. At that point all edits action are sent to the server and this one use it to update his chunk data and send a compressed version of all edit actions in that frame to all clients. In this system the client must have all the region data loaded (or all regions where a user is playing) so he can modify the data of that chunk when the server send the modifications (low cost part). The client only creates the mesh of the user active chunks (that's the high cost part).
thanks this is really good method but if i only send actions instead of chunk data, there might be a problem caused by synchronization. But if i remember correctly minecraft is struggling with that problem too. If you have a lag then someone place block before you. But since its a server auth environment, client has to obey server so there wont be desyn i hope
from marching-cubes-on-unity-3d.
emre, try my code, it follow a bit the solution given by Javier
from marching-cubes-on-unity-3d.
emre, try my code, it follow a bit the solution given by Javier
gonna check thanks
from marching-cubes-on-unity-3d.
8Kbs network usage when loading a lot of chunks together
The problem here is that is too much data trafic if you want scale the multiplayer. You only send the edits after the user end loading the region data on the initial connrection?.
from marching-cubes-on-unity-3d.
8Kbs network usage when loading a lot of chunks together
The problem here is that is too much data trafic if you want scale the multiplayer. You only send the edits after the user end loading the region data on the initial connrection?.
basically yes, i made mirror check if client has fully loaded the terrain
from marching-cubes-on-unity-3d.
Now the system allow the user edit the terrain each frame, maybe edits with a littel of cooldown between them reduce the traffic, for example wait the dig animation of the shovel end (1 edit per second).
from marching-cubes-on-unity-3d.
yeah, i may do that in the future
from marching-cubes-on-unity-3d.
Related Issues (15)
- Is there any option to do voxels smoother? HOT 1
- Sphere world generation HOT 2
- support liquid cube or water? HOT 1
- How to prevent interpolation? HOT 4
- Is the overhang right above slopes expected? HOT 5
- Too much vertices? HOT 1
- Alternative Biome Selection HOT 1
- Get Byte data from a vertex (placement objects) HOT 4
- Getting deeper HOT 3
- Changing VOXEL_SIDE Error HOT 2
- UV issue HOT 9
- How to apply texture to the whole chunk? HOT 2
- Questions HOT 1
- Chunks are saved even when SAVE_GENERATED_CHUNKS is false. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from marching-cubes-on-unity-3d.