0 votes

im using this script i wrote:

extends Spatial

func _ready():
    var noise = OpenSimplexNoise.new()
    noise.period = 80 <-------------------
    noise.octaves = 6

    var plane_mesh = PlaneMesh.new()

    plane_mesh.size = Vector2(400,400)
    plane_mesh.subdivide_depth = 200
    plane_mesh.subdivide_width = 200

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

    surface_tool.create_from(array_plane, 0)

    var mesh_instance = MeshInstance.new()
    mesh_instance.mesh = surface_tool.commit()  


func _process(delta):
    $Camera.rotate_y(delta * 0.5)

right at the begining there is the noise.period, whose value i want to replace by an random number, everytime i open the scene. can someone help?

i usually dont speak english, sorry if i spelled something wrong xD

Godot version 3.3
in Engine by (221 points)

1 Answer

0 votes


here are the Godot Docs for Radom number generation:

In your case you should randomize the seed:

noise.seed = randi()
by (1,067 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.