

That means if a client receives an edited block in the meantime, the generating block won't overwrite it. If you use asynchronous generation, note that blocks written with try_set_block_data will cancel blocks that are loading.
#Voxel tycoon multiplayer generator
If you want the client to generate the block locally, you could use the generator to make one with generate_block_async().

Voxels will only load based on what the server sends.

When a player joins, make sure a VoxelViewer is created for it, assign its network_peer_id and enable requires_data_block_notifications.The info.are_voxels_edited() boolean can tell if the block was ever edited: if it wasn't, you can avoid sending the whole data and just tell the client to generate the block locally. You can use VoxelBlockSerializer to pack voxel data into bytes. This will be a place where you may send the block to the client. This function will be called each time a new voxel block enters a remote player's area. Add a script to VoxelTerrain implementing func _on_data_block_entered(info).On VoxelTerrain, Enable block_enter_notification_enabled.Configure VoxelTerrain as normal, with a generator and maybe a stream.These properties are not necessarily specific to multiplayer, but were actually added to experiment with it, so they are grouped together.Ĭlient and server will need a different setup. VoxelTerrain has a Networking category in the inspector. The idea is for the server to be authoritative, and the client just receives information from it. There are some support functions you can use that can help putting together primitive multiplayer.
#Voxel tycoon multiplayer code

There is however assumption that the server also runs a version of the game. There is no assumption of the networking library you use, so it could be Godot RPCs, Valve Networking Sockets or even TCP. In general, the plan is to expose APIs to implement a client/server architecture. You can have a look at Godot's documentation page about networking. It is strongly recommended you learn it beforehand. This page assumes you already have knowledge in general multiplayer programming.
