#edit child property from parent (Line2D)

1 messages · Page 1 of 1 (latest)

novel matrix
#

hello!

i have a lamp scene that gets reused a ton in levels in the game i'm working on. i want the pole of the lamp to be editable per lamp, so i can have it visually connect to the terrain in novel ways, and i'm using a Line2D as a child for this.

my question is this: is "editable children" bad practice? i have the vague sense that it might be, and that i should somehow pass a PackedVector2Array from the parent to the child Line2D. however, if i try this in code and pass it in the _ready() function, i don't see it changing in the editor and can't use godot's built-in Line2D editor tools, which makes me have to guess and check my coordinates for points.

is there a better solution to this?

storm kelp
#

I personally try to avoid editable children since I've had issues in the past where changing the original scene caused errors in locations with editable children enabled.

Within a scene, you can add a scene reference as a child of another scene reference. So would it be possible to do something like this in your case:

* Lamp (This is a saved scene inserted by reference with all items common to all lamps)
   |---- Line2D for lamp post (This is a saved scene inserted by reference with typical line styles. Since it is a root level reference, you can edit the points.)
novel matrix
#

hmm yeah this could work

#

it's definitely an improvement over having a unique Line2D scene as child of every lamp

#

i'd still like it to be all one scene if at all possible, but until i can figure out how to get that to work this will be a good enough substitute i think

#

^ still open to ideas for this if anyone has them, but i'll probably start implementing it in the suggested way just so i can have something built lol

storm kelp
#

In that case, maybe flipping it so that the Line2D is a parent of the Lamp would be better. Then you can have a single scene, but still have access to the points since Line2D is at the top level.

novel matrix
#

oh true!