![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Insanee |
I’m new with godot. im trying to generate a world with perlin noise but i cant set the tiles of the tilemap because is like my tilemap is pointing to null or something
const ANCHO = 100
const ALTO = 100
var open_simplex_noise
const TILES = {"pasto":5 , "agua":0 , "tierra":6}
onready var grilla = $TileMap
func _ready():
randomize()
open_simplex_noise = OpenSimplexNoise.new()
open_simplex_noise.seed = randi()
open_simplex_noise.octaves = 4
open_simplex_noise.period = 256
open_simplex_noise.persistence = 0.349
_generate_world()
func _generate_world():
var tipo_celda
for x in ANCHO:
for y in ALTO:
tipo_celda = _generate_cell_type(open_simplex_noise.get_noise_2d(float(x),float(y)))
grilla.set_cell(x,y,tipo_celda)
func _generate_cell_type(noise_num):
if noise_num < 0.5:
return TILES.pasto
elif noise_num < 0.6 && noise_num > 0.5:
return TILES.tierra
else:
return TILES.agua
the var grilla keeps null and thats generating the error but i dont know why it keeps null after the assignment
Hi,
print(grilla)
See that it’s set to a Tilemap.
If it’s not… maybe use find_node to get the node.
deaton64 | 2020-08-18 23:04
it pointed null with find_node worked fined. thanks
Insanee | 2020-08-19 19:44