+1 vote

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

in Engine by (24 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.

by (726 points)
edited by

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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.