Solicey / minecraft-made-with-godot

Using Godot 4.2 and C#, only for learning purpose.
0 stars 0 forks source link

Can this work for Godot 4+ games with multiplayer and open world chunks? #1

Open WithinAmnesia opened 4 months ago

WithinAmnesia commented 4 months ago

Test chunks link: https://github.com/WithinAmnesia/ARPG/discussions/15

I'm trying to find a way to seamless load and unload chunks for a 2D multiplayer game project to make an open world with a working server using Godot 4.2.1.NET.

How can this work for multiplayer and what is needed for this to potentially work? What options can be used for chunk loading and unloading seamlessly in Godot 4.2.1.NET? Please give feedback.

Solicey commented 4 months ago

Yes, my demo does include multiplayer and dynamic chunk loading. As for multiplayer function, I use remote procedure call APIs provided by Godot. For chunk loading, I use surface tools to generate new 3D mesh when chunks need to be updated. Not quite sure whether surface tools are suitable for your 2D project, if you are using tilemaps.

At 2024-02-17 02:59:51, "WithinAmnesia" @.***> wrote:

Test chunks link: WithinAmnesia/ARPG#15

I'm trying to find a way to seamless load and unload chunks for a 2D multiplayer game project to make an open world with a working server using Godot 4.2.1.NET.

How can this work for multiplayer and what is needed for this to potentially work? What options can be used for chunk loading and unloading seamlessly in Godot 4.2.1.NET? Please give feedback.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

WithinAmnesia commented 4 months ago

I am doing a from scratch build now for the multiplayer chunk system. What should I do for the server and the data and chunk storage? https://github.com/WithinAmnesia/ARPG/discussions/16

WithinAmnesia commented 4 months ago

How do you store your multiplayer chunk data? Is this similar to?: https://www.youtube.com/watch?v=Q2iWDNq5PaU https://github.com/xen-42/Simplified-godot-voxel-terrain https://github.com/xen-42/Minecraft-Clone https://github.com/pvini07BR/mijocraft/issues/2

WithinAmnesia commented 4 months ago

"Yes, my demo does include multiplayer and dynamic chunk loading. As for multiplayer function, I use remote procedure call APIs provided by Godot. For chunk loading, I use surface tools to generate new 3D mesh when chunks need to be updated. Not quite sure whether surface tools are suitable for your 2D project, if you are using tilemaps." - https://github.com/Solicey/minecraft-made-with-godot/issues/1#issuecomment-1951569213

How does your project do saving chunk data for multiplayer? Can it save the chunk data to disk? Then can the project have the server be able to load only the chunk data around the clients on the same server? So it can have a big world and lot of people on the server but the server only loads what is around the player to save performance?

I found this too is your project like this sort or how is it different / how does it work for its data solution sin multiplayer?: https://github.com/pvini07BR/mijocraft/issues/2#issuecomment-1953209200 "What I know is that translating GDScript code to C# isn't that hard. it uses the same names for the classes, functions, members and variables, except they are in PascalCase because that is the standard for C#.

But as I can remember by far, the chunk system works like this: The chunk is actually a Custom Resource. It stores all the block IDs in a array, you can do it in a 2D array if you prefer. It's an array of integers basically, with the number 0 representing air block.

so, what the server and client sends between each other is just the chunk resource data. and the chunk mesh is actually built in the client based on the chunk resource data. that's it.

this chunk resource data can also be saved in disk to be loaded later."

There is mention here of chunks being stored as integers / numbers and sending the client the chunk data that the client builds its chunk mesh / world sourced from the chunk resource data stored as an array of integers: Is your multiplayer chunk data storage system similar to this?

"It stores all the block IDs in a array, you can do it in a 2D array if you prefer. It's an array of integers basically, with the number 0 representing air block... what the server and client sends between each other is just the chunk resource data. and the chunk mesh is actually built in the client based on the chunk resource data."

What can I do to learn how this project stores its multiplayer chunk data with the server and do you have a guide or documentation or a guide on how the server and client work together with chunk data? Is there a tutorial or something that can help or something that helped you learn this?

"I use remote procedure call APIs provided by Godot. For chunk loading, I use surface tools to generate new 3D mesh when chunks need to be updated. Not quite sure whether surface tools are suitable for your 2D project, if you are using tilemaps."

Can you give more detail on these with regards to how you store the chunk data with the server and remote procedure call APIs provided by Godot and using surface tools to generate new 3D mesh when chunks need to be updated as well? Also what would you recommend for using something like surface tools but with a 2D project that is able to use tilemaps?

Is it reasonable to try and learn from both https://github.com/pvini07BR/mijocraft/ and your project and make a top down 2D multiplayer chunk system that can store millions of tiles / thousands of chunks that have hundreds of tiles on the server but only access where are around each client and have the clients build their chunks from the integers / numbers for the chunks data from the server / and or how minecraft multiplayer works?

Can these projects be learned from and a new from scratch fresh multiplayer chunk system be made that takes the best of both for a 2D top down massive scale open-world that runs thousands of clients (~2K to upwards of 16K is the target) on the same server? It is 2D and the world is hand made mostly and it has very very layers but uses other areas for subterranean areas and interiors.

What would a 2D version of this look like that can save the world and have a mostly hand made world of at least 100 x (1,024 x 1,024) = 104,857,600 with 16x16 pixel tiles?

How can a 2D top down simpler game learn from your big 3D game and save the chunk data for a massive open-world multiplayer seamless chunk system?

Please ask any questions and share your thoughts and suggestions. What should be done to to make this big 3D game more into 2D and keep the chunk data storage server and client system? All feedback is welcome.

WithinAmnesia commented 4 months ago

How do we test the multiplayer and the server with the Godot editor? I run 4 instances and it looks like in needs a server to host or something? I wish I read Chinese better lol. What does one do to test the multiplayer? How does this multiplayer work and what are the steps needed to get the multiplayer working?

Solicey commented 4 months ago

How do we test the multiplayer and the server with the Godot editor? I run 4 instances and it looks like in needs a server to host or something? I wish I read Chinese better lol. What does one do to test the multiplayer? How does this multiplayer work and what are the steps needed to get the multiplayer working?

Sorry that I haven't replied in time. The first button in the main menu refers to "Hosting Game", the second refers to "Joining Game", the third refers to "Options", in which you can modify the number of chunks rendered, the last one refers to "Quit Game".

After clicking the "Hosting Game" button, you can modify "World Seed", "Opening Port" and "Host Player Name". Then click the button on the right to host the game.

If you are testing this demo on a single PC, then you can simply start another game process, click "Joining Game" button in the main menu. There are also three fields to modify: "Server Address", "Server Port" and "Client Player Name". You can modify "Client Player Name" as you wish, but make sure "Server Address" is "127.0.0.1", and "Server Port" is the same as the host's setting.

If you are testing on different PCs under the same LAN, you might want to check your host's LAN IP address, and modify "Server Address" when joining the game.

WithinAmnesia commented 4 months ago

I made a lot of progress with the godot_voxel work and it works for the seamless chunk system in multiplayer: https://github.com/Zylann/voxelgame/issues/101#issuecomment-1958792464 + https://github.com/WithinAmnesia/ARPG/discussions/16 + https://github.com/Zylann/voxelgame/issues/104

WithinAmnesia commented 4 months ago

I still need to learn a lot about servers and web hosting too. What should I do for multiplayer hosting on the we and a dedicated server solution? All feedback is welcome.

Solicey commented 4 months ago

I still need to learn a lot about servers and web hosting too. What should I do for multiplayer hosting on the we and a dedicated server solution? All feedback is welcome.

It seems like Voxel Tools has introduced some ways of supporting multiplayer: https://voxel-tools.readthedocs.io/en/latest/multiplayer/.

Besides, from the link you've given above, I guess you are trying to make a 2.5D game instead of a 2D one?

WithinAmnesia commented 4 months ago

I tried the 2D route but the complexity to get the working multiplayer seamless chunk system was too much vs. using the 3D blockygame demo modified a bit from Godot_voxel. I can use 2D assets with a top down camera and get the production benefits of 2D with the vast engine chunk system and working multiplayer of godot_voxel / blockygame demo. Yet there are some feat features such as item storage and entities that need to be added with the blockygame chunk system then its 9/10 ready to make a big game. Minecraft system chests and entity spawner system is all that is left really for starting the big world building work. Then once 9/10 of the big dev tools and system demos are made it is big game dev time using and making and providing guides and examples for open source forever free community tools. Then it is time after the community has it's working open source forever free dev tools examples for building big games (I wish I had decades ago) I can be more fulfilled to build a big game world.

I'm trying to add a chest block like in minecraft (where the chest can open a gui that has the player inventory and the chest / container contents inside and of the chest block is broken it drops all the items like in minecraft) and an entity spawn / entity system. Any suggestions? I Have been looking at youtube godot guides but they are not 100% great for blockygame uses dynamic voxel blocks for pretty much everything. I think Zylaan the Godot_voxel author suggested using an array of items with the added chest block's voxel_metadata but I'm not sure how to get the gui part working too?

The entities are tricky too for they are not blocks but I suggested a entity spawner block voxel solution that has spawn logic in the voxel_metadata. What do you think and suggestion? What should be done for adding chests and entities to the blockygame demo for community examples? All feedback is welcome.

WithinAmnesia commented 4 months ago

Do you have any free time to look at the code for this RPG Inventory from scratch tutorial and see how it can be translated / implemented with the Blockygame multiplayer demonstration? What should be done? What are your thoughts and suggestions? All feedback is welcome. https://github.com/devloglogan/MultiplayerFPSTutorial/issues/13 https://github.com/WithinAmnesia/ARPG/blob/ARPG-Infinite-Worlds/DevLogLogan%20RPG%20Inventory.zip Here is the Blockygame demo too it needs the Godot_Voxel engine module to work: https://github.com/WithinAmnesia/ARPG/blob/ARPG-Infinite-Worlds/Infinite_Worlds_V.000.006.1.zip