How to share a property over different nodes ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Superyen

Hi everyone :slight_smile:

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

:bust_in_silhouette: Reply From: duke_meister

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.

Thank you :slight_smile:

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

Superyen | 2018-07-11 08:58