Godot Version 4.2.2 stable
Hello! While I’m not new at programming, I’m new to game dev in general. I’ve modelled a “room” and named it as “base_cell”. The idea is when I click any of the walls in the base cell, it creates another cell in that direction and removes the connecting walls.
've got a Node3D for every wall and they are all under the base_cell node which is instanced in my main scene. The mouse click logic is attached to every Wall node, since it makes sense that I need to know which Wall was clicked on. However, the code I’ve mustered up to create a new base_cell hasn’t worked
extends Node3D
func _instantiate_cell(name):
var root = self.get_parent()
var new_cell = root.duplicate()
for child in root.get_children():
if child.name == name:
continue
new_cell.add_child(child.duplicate())
However, I can’t put the logic for cell duplication on the root Node3D since I’d lose access to the input_event call. Is my entire Node arrangement logic wrong? Is it possible to handle this signal in a parent node? Did I paint myself into a corner by trying to reuse as much code as possible? Is there an appropriate way to handle this? Should I just load the main scene inside the wall script and do it that way?