Skip to content

Commit

Permalink
Merge pull request #160 from BenjaTK/chunk-loader-fix
Browse files Browse the repository at this point in the history
Clarify chunk generation tutorial and make world_size hide when infinite
  • Loading branch information
BenjaTK authored Aug 21, 2024
2 parents a1f74a2 + 40e3ec1 commit e306e92
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ extends GeneratorSettings2D
@export var tile: TileInfo
@export var noise: FastNoiseLite = FastNoiseLite.new()
## Infinite worlds only work with a [ChunkLoader2D].
@export var infinite := false
@export var infinite := false :
set(value):
infinite = value
notify_property_list_changed()
@export var world_length := 128
## The medium height at which the heightmap will start displacing from y=0.
## The heightmap displaces this height by a random number
Expand All @@ -19,3 +22,8 @@ extends GeneratorSettings2D
@export var min_height := 0
## If [code]true[/code], adds a layer of air ([code]null[/code] tiles above the generated terrain.
@export var air_layer := true


func _validate_property(property: Dictionary) -> void:
if property.name == "world_size" and infinite == true:
property.usage = PROPERTY_USAGE_NONE
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ extends GeneratorSettings2D
tile_data.settings = self
@export var noise: FastNoiseLite = FastNoiseLite.new()
## Infinite worlds only work with a [ChunkLoader].
@export var infinite: bool = false
@export var infinite: bool = false :
set(value):
infinite = value
notify_property_list_changed()
@export var world_size: Vector2i = Vector2i(256, 256):
set(value):
world_size = value
Expand All @@ -35,3 +38,8 @@ extends GeneratorSettings2D
falloff_map = value
if falloff_map != null:
falloff_map.size = world_size


func _validate_property(property: Dictionary) -> void:
if property.name == "world_size" and infinite == true:
property.usage = PROPERTY_USAGE_NONE
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ extends GeneratorSettings3D
@export var tile: TileInfo
@export var noise: FastNoiseLite = FastNoiseLite.new()
## Infinite worlds only work with a [ChunkLoader3D].
@export var infinite := false
@export var infinite := false :
set(value):
infinite = value
notify_property_list_changed()
## The size in the x and z axis.
@export var world_size := Vector2i(16, 16)
## The medium height at which the heightmap will start displacing from y=0.
Expand All @@ -33,3 +36,8 @@ extends GeneratorSettings3D
falloff_map = value
if falloff_map != null:
falloff_map.size = world_size


func _validate_property(property: Dictionary) -> void:
if property.name == "world_size" and infinite == true:
property.usage = PROPERTY_USAGE_NONE
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions docs/tutorials/chunk_generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ Once this node has been added to the tree, you need to assign the `Generator` an

![assign-nodes.gif](..%2Fassets%2Ftutorials%2Fchunk_generation%2Fassign-nodes.gif)

![Set the settings' infinite property to true](../assets/tutorials/chunk_generation/infinite.png)

It's also important that you set the settings' `infinite` property to `true`!

After this has been done ... **_VOILÀ!_** You now have Chunk Generation enabled for your 2D world! Once this is done, you can play around with the settings of the ChunkLoader to tune it to your liking!

### It's running really slowly...
Expand Down

0 comments on commit e306e92

Please sign in to comment.