donte5405 / godot-chunk

Primitive & simple chunk system for Godot
MIT License
1 stars 0 forks source link

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

Open WithinAmnesia opened 6 months ago

WithinAmnesia commented 6 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.

donte5405 commented 6 months ago

I'm not planning to add support for Godot 4 but it shouldn't be too difficult to convert it.

For the proposal itself I don't think this project will be very appropriate since this is only for 3D mode, it doesn't support lazy-loading without extra layer of some smart helper scripts (which I planned to add it in the future if I have enough motivation). The chunk itself must be small enough to be (initially) loaded without causing hiccups (threads don't help on the node adding step because it's still single-threaded). Not to mention that with this addon, chunks will always be forced to be unloaded if the camera moves away farther enough, and this script doesn't support manual unloading yet (which, of course, will also cause hiccups because Godot doesn't have garbage collection).

On first thought I could suggest, you should design the client to also work as a server because it will be much easier to design the server-side unless you are experienced with the separating client-server method. When deploying the game as a server it could be configured to load all chunks but without visual resources (you could write simple resource stripping scripts and then re-bake them as server-only chunks). In client mode it will use the visual chunks and load/unload them without worrying that the game logic will be broken since it's gonna be at least partially calculated in the server. In the build you could also strip anything that's not required for both client and server. This way it's much easier to both design the game and build a game with good architecture. It's quite a standard for making online games nowadays.

On the navigation slowness that you faced, pretty much all games faced the exact same issue if the area is too large in a same navigation layer (a lot more area for the A to calculate optimal path https://www.youtube.com/watch?v=CgW0HPHqFE8). I pretty much suggest against the use of A if it's not absolutely necessary. If entities don't need to move out the area, you could instead use some sort of dumb navigation algorithms to help out the performance (such as https://youtu.be/HP4ObKlCe6w?t=447), or hand the task to the client instead especially if the navigation isn't something that needs to be calculated cross-chunks. Noting that this way you expose a vulnerability that hackers could abuse, and you should always try to confine the limitations that the client could do with it.

WithinAmnesia commented 6 months ago

Also https://github.com/Zylann/voxelgame/issues/101#issuecomment-1958792464 + https://github.com/WithinAmnesia/ARPG/discussions/16#discussioncomment-8550378 Big 2D/3D hybrid progress update! It all works!

WithinAmnesia commented 6 months ago

I watched a lot of the 8-bit guy and yeah Astar navigation is really good. its just how to use it with chunk system where the data is streamed? Can you take a look at BlockyGame and Godot_Voxel to see more insights and it has a big breakthrough with the working multiplayer seamless chunk system for sure.