I want to make an isometric (almost) endless world with tiles and chunks. I want the chunk to contain 20x20 tiles. The question is, how can I do it. I want the chunks past the player screen to unload but when a player goes back there it loads like it was before. Is there a clear tutorial for the latest Godot version unless someone in here could teach me.
Extra:
I want to add biomes too. How can I make so that another tile map layer gets generated and the right tiles into right biomes)
#I need help with chunk system!
1 messages · Page 1 of 1 (latest)
You need to store the changes to the terrain so you can re apply them when you return. Or alternatively pre-save the terrain before the game starts. Then load it.
What if I want to reset the world to test and update some things.
I am new to the world generation and most of the code in Godot.
This would not really stop you from doing that.
Think of it like how Minecraft does it.
When you create a new world, it always start from the initial state.
If you mean without making a new world, you can re-run the code you use to generate it.
As for the biomes, that sounds like a separate system from the basic generation of the terrain.
okay, but is there some kind of an in depth tutorial about it?
There must be plenty, with the amount of Minecraft clones. Altho probably not specific to Godot.
The key part is noise, for that you have the NoiseTexture and FastNoiseLite classes.
The blocks themseles COULD be from a GridMap if they are not too deep. But you may run into performance problems at larger scales.
do I have to make two separate scripts for that. one for chunks and the other for biomes and third one for trees and foilage?
This may need several, but it depends on how you will handle it.
As always there are a LOT of ways you can go about it.
atm i would focus on making the terrain saving stuff work. And then look onto how to add more features.
that's what Im trying to do rn
Okay, I'll start writing something and working on it (I dont have any idea how to make it really work). I'll try to find some (working) tutorials.
I think Minecraft has a 2D map that defines the biome of a column of blocks (it was changed to be a 3D map as of the cliffs and caves update, but it was pretty advanced stuff, not sure how they managed without a performance hit)
Whenever something that relies on biomes has to check for that, it queries that 2D map.
I think folliage just uses a shader to recolor the block, and correlates a color to a coordinate of the biome map to find out which to use.
But the main problem is that I cant find any tutorials for the chunk handling system
Each chunk can just be its own dictionary.
Which can then be inside another dictionary, quick example:
#Chunk contains Blocks
class_name Chunk
var blocks: Dictionary[Vector3i, Block]
#World contains Chunks
class_name World
var chunks: Dictionary[Vector3i, Chunk]
As a sort of implementation:
func generate_world(size: Vector3i) -> World:
var world := World.new()
for x in size.x:
for z in size.z:
var coordinate: Vector3i = Vector3i(x, 0, z)
world.chunks[coordinate] = Chunk.new()
world.chunks[coordinate].someChunkVariable = 29
world.chunks[coordinate].generate_blocks()
is it for 2d or 3d, my game is 2d and pixelated
Oh, then you could just use a Vector2i.
Even Minecraft had 2D chunks beforehand.
This would generate a full world.
But it is obviously missing a lot of stuff.
Like, what does generate_blocks() do?
How do chunks know how to generate in comparison to the neighboring ones?
Should the block generation be done without chunks, THEN they should be put in chunks for storage?
What other properties does a Block need? How would you give it physics or a model?
As i said, there is a lot of ways to go about this.
so if I want only one block to be seen for testing what should I add then
is it var grass_atlas_position = Vector2i(0,1) and then sth to the function
First you should define what a block is.
A TileMap may be good for this.
i do not understand the context of this?
is it a tile map or a tile map layer in godot 4.3
TileMapLayer preferably, TileMap is deprecated and may be removed soon.
I understand how the system works but I dont have any idea how to fully implement it into the game.
Always one step at a time.
Think of what you need, then break those needs into smaller needs and tackle one at a time.
Like, do you need to detect what tile is at X coordinate? First you have to define a tile (not even the whole tile, just start by its position or "type"), then how you store it, then how you access it.
It is all small steps.