Godot Version
4.2.2
Question
Hi
I have a function in a custom class to duplicate a 3d node then adding it into as child.
(“grid” is just a list of object array that holds some pregenerated position etc data)
map.gd
extends Node3D
class_name HexMap
var geo
func _init(_geo):
geo=_geo
generate(geo)
func generate(geo):
var inst = geo
for h in grid:
var obj = tgen(inst, h)
add_child(obj)
func tgen(tile, h: obj):
var h = tile.duplicate()
h.translate(h.position)
add_child(h)
Then I use this to generate the objects in a Node3d object in the scene (atatched as a script to it)
scene_object.gd
var geo= preload ("res://prop.tscn")
func _ready():
var inst_geo = geo.instantiate()
map=map.new(inst_geo)
The problem I have is that I do not see the generated objects that have been added as a child ( add_child(obj) ) in the scene. I can run that generator in the actual scene node, that but that gets convoluted for me since I am trying to solve all that in that class.
what am I doing wrong? When I print the child of “scene_object” I see that it lists those objects as childs but not visible in the viewport.