Help Using Noise2D

Godot Version

4.2.1

Question

I can’t seem to properly use the get_noise_2d method. My code looks like this. (I haven’t even implemented anything for setting tiles so far because I can’t get any viable noise values).

get_noise_2d returns 0 for every single value. My noise texture I am using is just a default FastNoiseLite, the same as if I did var noise:= FastNoiseLite.new()


@export var NOISE: NoiseTexture2D
@export var max_x:= 100.0 #3000
@export var max_y:= 100.0 #2000
@onready var noise = NOISE.noise

func _ready() -> void:
	#randomize()
	NOISE.noise.seed = randi()
	noise.fractal_octaves = 0
	noise.fractal_gain = 0.5
	noise.fractal_lacunarity = 2
	generate_level()

func generate_level():
	for x in max_x:
		for y in max_y:
			var tile_noise = noise.get_noise_2d(x, y)
			print(str(noise.get_noise_2d(x, y)))
1 Like

I am not 100% but I would try moving the var noise declaration into the _ready() function after the seed assignment… I could see them being different objects potentially. It’s been a while since I played with gdscripting noises.

Tried and still didn’t work, also just tried not setting a seed and using the default 0, also didn’t work.

Problem was me setting the fractal_octaves to zero, it doesn’t work when it is zero. I was looking at an old tutorial for 3.3.1 and they set the octaves to zero. I don’t think I will be following that tutorial anymore :stuck_out_tongue: I will probably have an easier time figuring it out myself than trying to use an older tutorial.