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

    add_child(mesh_instance)


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

1 Answer

0 votes

Hey,

here are the Godot Docs for Radom number generation:
https://docs.godotengine.org/en/latest/tutorials/math/random_number_generation.html

In your case you should randomize the seed:

noise.seed = randi()
by (710 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 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 webmaster@godotengine.org with your username.