godot_voxel
godot_voxel copied to clipboard
[Question] How do set_voxel_metadata and for_each_voxel_metadata_in_area work?
How do set_voxel_metadata and for_each_voxel_metadata_in_area work? Explanations of what they do and how to use them are missing from the documentation.
set_voxel_metadata
stores the given data into the terrain at the specified position. It will be saved alongside voxel data if a VoxelStream is used. The data can be anything Godot can serialize: bool, float, int, Vector2, Vector3, Array, Dictionary, String etc. Object types wont trigger errors, but saving wont work with them. Cyclic references will not work either. This feature can be used to store sparse data associated with a particular voxel, notably in games working similarly to minecraft (for example, contents of a chest).
for_each_voxel_metadata_in_area
iterates through every voxel that contain metadata in the given area, and calls the given function for each of them.
The API documentation is getting outdated since the switch to Godot 4, the doctool needs to be ran again and more descriptions need to be written.