Hi!
i've got a little problem on my world generation: i want to make it infinite.
the terrain: https://ibb.co/4F7Pswv
the end of the terrain: https://ibb.co/nLQd1Xq (ignore the water in this one)
my code:
extends Spatial
var rng = RandomNumberGenerator.new()
#################world generation##################################
func _ready():
#generating random number for seed
rng.randomize()
var number = rng.randf_range(1, 1500.0)
print(number)
var plane_mesh = PlaneMesh.new()
var noise = OpenSimplexNoise.new()
noise.seed = number
noise.period = 185
noise.octaves = 8
plane_mesh.size = Vector2(900,900)
plane_mesh.subdivide_depth = 450
plane_mesh.subdivide_width = 450
var surface_tool = SurfaceTool.new()
surface_tool.create_from(plane_mesh, 0)
var array_plane = surface_tool.commit()
var datatool = MeshDataTool.new()
datatool.create_from_surface(array_plane, 0)
for i in range(datatool.get_vertex_count()):
var vertex = datatool.get_vertex(i)
vertex.y = noise.get_noise_3d(vertex.x, vertex.y, vertex.z) * 60
datatool.set_vertex(i, vertex)
for i in range(array_plane.get_surface_count()):
array_plane.surface_remove(i)
datatool.commit_to_surface(array_plane)
surface_tool.begin(Mesh.PRIMITIVE_TRIANGLES)
surface_tool.create_from(array_plane, 0)
surface_tool.generate_normals()
var mesh_instance = MeshInstance.new()
mesh_instance.mesh = surface_tool.commit()
mesh_instance.set_surface_material(0, load("res://terrain_material.tres"))
mesh_instance.create_trimesh_collision()
add_child(mesh_instance)
(the pictures dont show all of the world)
if someone has an idea for infinite world generation (that doesnt destroy my pc) based on this code, i would like to hear it :)
thanks already