Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify chunk generation tutorial and make world_size hide when infinite #160

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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