How do I make a property of a subnode accessible as a property of its parent?

Godot Version

4.3.stable.nixpkgs

Question

I’m making a game and I’d like to make some properties of subnodes of a scene accessible as properties of the scene itself so that they can be assigned in each scene using it to different values. Currently, I have the following code:

@export var west_wall_pos: float:
	set(new_value):
		$westWall.position.x = new_value
	get:
		return $westWall.x

(same for other ones)

It seems to work (according to the debug output; the game doesn’t show anything, but this may be unrelated), but the editor doesn’t show it properly. Is there a better way to do this?

If you want to have things updated in the editor you need to change the parent scene script into a @tool

1 Like

You can right-click and select “Editable Children” on instantiated scenes to edit the children directly

Note that the variable west_wall_pos is not being updated in your code.
There is also something wonky here as you are using $WestWall.position in the setter and returning $WestWall.x in the getter.

It might be better to just offer up the node as an export.

#Note that I am guessing at $WestWall node type   
@export var west_wall:Node2D