0 votes

Hi everyone :)

I would like to be able to "link" any property of any type to several properties of the same type. How can it be made possible ?

Scenario :
Node A owns a property P1 of type T
Node B owns a property P2 of type T
Node C owns a property P3 of type T

Link P1 to P2 and P3

P2 and P3 are replaced by P1

When P1 changes, P2 and P3 change accordingly

Thank you very much

asked Jul 10 in Engine by Superyen (22 points)

1 Answer

+1 vote

Just have a signal "p1_changed" that NodeA sends with the changed value as a param, and connect it to NodeB and NodeC? When received, change the values.
ed: so for the 'any property of any type' scenario, could have the node and property name as the params, then could either get the node, then the value, or also pass the value as above. I use C# so hopefully I'm not too off track. This could be handled in C# with OnPropertyChanged events, or custom events.

answered Jul 10 by duke_meister (684 points)
edited Jul 10 by duke_meister

Thank you :)

My solution for the primitive types right now is to keep "destinations" (as you say, the node and the property name) in an array in the parent node and copy values each frame in the _process functions
I will try to create my own signals it's probably better ^^

For the rest, i just assign the references : it does the trick because i differentiate outputable properties from inputable properties so if i can link P1 to P2 and P3, P1 is an output so i know the reference will not change

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.