#I need help with chunk system!

1 messages · Page 1 of 1 (latest)

charred glen
#

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)

hollow seal
charred glen
#

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.

hollow seal
#

As for the biomes, that sounds like a separate system from the basic generation of the terrain.

charred glen
#

okay, but is there some kind of an in depth tutorial about it?

hollow seal
#

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.

charred glen
#

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?

hollow seal
#

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.

charred glen
#

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.

hollow seal
#

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.

charred glen
#

But the main problem is that I cant find any tutorials for the chunk handling system

hollow seal
#

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()

charred glen
#

is it for 2d or 3d, my game is 2d and pixelated

hollow seal
#

Oh, then you could just use a Vector2i.

Even Minecraft had 2D chunks beforehand.

charred glen
#

is this the whole chunk code?

#

or a part of it?

#

I understand a little bit

hollow seal
#

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.

charred glen
#

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

hollow seal
#

First you should define what a block is.
A TileMap may be good for this.

hollow seal
charred glen
#

is it a tile map or a tile map layer in godot 4.3

hollow seal
#

TileMapLayer preferably, TileMap is deprecated and may be removed soon.

charred glen
#

I understand how the system works but I dont have any idea how to fully implement it into the game.

hollow seal
#

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.

charred glen
#

Okay first of all, how do I tell the game to place one tile into a chosen coordinate?

#

I hope I am not wasting your time

#

most of the old tutorials are made years ago and dont have the same systems